Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Extended semaphores of flask

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

# pip install blinkerfrom blinker import signals = signal ('semaphores ')def each(num): print("each {}".format(num))def full_singal(num): print("full_time {}".format(num))s.connect(each)s.connect(full_singal, sender = 2)for num in range(1, 4): s.send(num) The result is as follows: each 1each 2round 2each 3#or abbreviated:from blinker import signals = signal("test start")@s.connectdef each(round) print("each {}".format(round))Flask built-in signal: flask.template_rendered: sent when template rendering is successful, this signal is called together with the dictionary of template instance template context. Flask.request_started: After the request context is established, sent before request processing begins, subscribers can access the request using standard proxies such as request. flask.request_finished: Sent before the response is sent to the client, may pass a response. flask.got_request_exception: Sent when an exception is thrown in request processing, the exception itself is passed to the subscription function via execution. Flask.request_tearing_down: Sent when destruction is requested, it is always called, even if an exception occurs. Flask.appcontext_tearing_down: Sent when application context is destroyed, it is always called, even if an exception occurs.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report