-
Notifications
You must be signed in to change notification settings - Fork 13
Description
This issue describes a theoretical race condition that should be safely handled in the client and can happen due to random network delays.
There are two awaited coroutines and a currently empty RequestQueue
async def checking_if_empty(...):
await rq.finished()
...do stuff...
async def adding_requests(...):
await rq.is_finsihed()
...do stuff...
Imagine that both of them are started, and adding_requests
was started first
asyncio.create_task(adding_requests)
asyncio.create_task(checking_if_empty)
Due to network delay randomness, it can happen that the second request is_finsihed
will read API first and in such case it will respond True. But that is False as the client is currently trying to add some requests. It is the responsibility of the client and not the API to be aware of own add_request
call and probably even shortcut into returning False to is_finsihed
method without the need to reach the API.
This might have already been handled on the RequestQueue
level by RequestQueue._add_requests_tasks