Skip to content

Add test and ensure that RequestQueueClient is aware of own add_request calls #519

@Pijukatel

Description

@Pijukatel

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

Metadata

Metadata

Assignees

Labels

debtCode quality improvement or decrease of technical debt.t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions