Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute QueueManager items in order #3571

Closed

Conversation

emontnemery
Copy link
Contributor

@emontnemery emontnemery commented Apr 3, 2024

Execute QueueManager items in order and change queue items to be Iterable[Coroutine] where the iterable items are executed in parallel and thus not guaranteed to be executed in order.

This is needed by #3572

@emontnemery
Copy link
Contributor Author

emontnemery commented Apr 8, 2024

Tests should be added after #3357 is merged

self.async_register_repository(
repository_full_name=repo,
category=category,
default=True,
)
)
self.queue.add(tasks)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the tasks in the queue cleaned up if there are remaining tasks on shutdown?

We should probably not add coroutines directly but either coroutine functions or asyncio.Tasks so we avoid running into "coroutine was never awaited".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a valid point, but I think that should be changed separately as it doesn't really have anything to do with the changes in this PR,

@MartinHjelmare
Copy link
Contributor

The reason for this PR isn't really clear in the PR description.

@emontnemery emontnemery marked this pull request as draft April 9, 2024 09:51
@emontnemery emontnemery force-pushed the queue_manager_execution_order branch from a05c858 to 068d0c9 Compare April 10, 2024 14:40
@emontnemery emontnemery force-pushed the queue_manager_execution_order branch from 10f74d2 to 3105551 Compare April 10, 2024 15:17
@emontnemery emontnemery marked this pull request as ready for review April 10, 2024 15:17

@property
def has_pending_tasks(self) -> bool:
"""Return a count of pending tasks in the queue."""
"""Return if there are pending tasks in the queue."""
return self.pending_tasks != 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return self.pending_tasks != 0
return len(self.queue) != 0

As we remove things from queue this should be a simple count instead of pending_tasks since that one now does a sum of all childs

for task in queue_item:
local_queue.append(task)

for task in local_queue:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking now, this looks like a bug?
These should be removed after the items have been executed right?
So the properties exposed in this class would be correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not obvious what is correct here. If removing the items early, we consider the tasks no longer in the queue when execution starts. If removing the items late, we consider the tasks no longer in the queue when execution is finished.

@emontnemery emontnemery marked this pull request as draft April 15, 2024 12:54
@emontnemery
Copy link
Contributor Author

After some discussion on discord, I'm not sure we should merge this.

@ludeeus
Copy link
Member

ludeeus commented Apr 17, 2024

Let's not move forward with this one, but keep a mental note about the known queue items cleanup for the exposed properties.

@ludeeus ludeeus closed this Apr 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants