In this section, we'll take a look at more ways to share data between tasks and synchronize their operations.
Synchronizing multiple tasks
Synchronization primitives
The asyncio package provides lock, semaphore, event, and condition classes that are pretty similar to the ones we looked at in the context of concurrent.futures. They provide the same method names and fulfill the same roles. The important difference is that for asyncio's versions, some of the methods are coroutines and some are not, as shown here:
Specifically, in each case, the acquire and wait methods, if they exist, are coroutines that must be called by await.
This is because they need to be able to pause until some specific thing happens, and only...