Working with signals

Signals can be thought of as events that happen in our application. These events can be subscribed by certain receivers who then invoke a function whenever the event occurs. The occurrence of events is broadcasted by senders who can specify the arguments that can be used by the function to be triggered by the receiver.

Tip

You should refrain from modifying any application data in the signals because signals are not executed in a specified order and can easily lead to data corruption.

Getting ready

We will use a Python library called blinker, which provides the signals feature. Flask has inbuilt support for blinker and uses signaling to a good extent. There are certain core signals provided by Flask.

In this recipe, we will use ...

Get Flask Framework Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.