In the previous chapter, we discussed various concurrency implementation models available in Python. To better explain the concept of concurrency, we used the following definition: Two events are concurrent if neither can causally affect the other.
We often think about events as ordered points in time that happen one after another, often with some kind of cause-effect relationship. But, in programming, events are understood a bit differently. They aren't things that happen. Events in programming are just independent units of information that can be processed by the program. And that very notion of events is a real cornerstone of concurrency.
Concurrent programming is a programming paradigm for processing concurrent events. And there is a generalization of that paradigm that deals with the bare concept of events – no matter whether they are concurrent or not. This approach to programming, which treats programs as a flow of events, is called event-driven programming.
It is an important paradigm because it allows you to easily decouple even large and complex systems. It helps in defining clear boundaries between independent components and improves isolation between them.
In this chapter, we will cover the following topics:
- What exactly is event-driven programming?
- Various styles of event-driven programming
- Event-driven architectures
After reading this chapter, you will have learned what the most common techniques of event-driven programming are in Python and how to extrapolate these techniques to event-driven architectures. You'll be also able to easily identify problems that can be modeled using event-driven programming.