-
-
Notifications
You must be signed in to change notification settings - Fork 472
feat(loop): add optional overlap support to allow concurrent loop executions #2771
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
base: master
Are you sure you want to change the base?
Conversation
…xecutions Added a new overlap parameter to the loop decorator and Loop class to control whether loop iterations can run concurrently. When set to True, the next iteration will not wait for the previous one to finish, allowing overlapping executions—useful for long-running tasks that should not delay subsequent runs. Defaults to False to preserve current behavior. Signed-off-by: Lumouille <[email protected]>
Signed-off-by: Lumouille <[email protected]>
Signed-off-by: Lumouille <[email protected]>
…t: 'overlap' Signed-off-by: Lumouille <[email protected]>
Signed-off-by: Lumouille <[email protected]>
Exception in callback Future.set_result(True) handle: <TimerHandle when=203424.768941542 Future.set_result(True)> Traceback (most recent call last): File "/usr/local/lib/python3.11/asyncio/events.py", line 84, in _run self._context.run(self._callback, *self._args) asyncio.exceptions.InvalidStateError: invalid state Signed-off-by: Lumouille <[email protected]>
Signed-off-by: Lumouille <[email protected]>
sorry i renamed the branch and it deleted the other one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add an additional parameter for limiting the number of active tasks
Co-authored-by: plun1331 <[email protected]> Signed-off-by: Lumouille <[email protected]>
Co-authored-by: plun1331 <[email protected]> Signed-off-by: Lumouille <[email protected]>
maybe: If overlap is: True: allow overlapping tasks with no limit (default). False: do not allow overlapping (wait for task to finish). An int: allow overlapping up to n concurrent tasks. |
add name for the tasks Signed-off-by: Lumouille <[email protected]>
Signed-off-by: Lumouille <[email protected]>
Signed-off-by: Lumouille <[email protected]>
Signed-off-by: Lumouille <[email protected]>
so i did some change but i'll debug that tonight + if someone can tell me about my implementation in case overlap if false, should i stick with await coro ? or else its good like so |
Signed-off-by: Lumouille <[email protected]>
not ready for review |
Signed-off-by: Lumouille <[email protected]>
Signed-off-by: Lumouille <[email protected]>
Signed-off-by: Lumouille <[email protected]>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, one extra thing, tasks should be removed from _tasks
after they complete (otherwise the list will just grow infinitely)
Signed-off-by: Lumouille <[email protected]>
I think we just change the docs to specify that it represents the number of loops that have been started |
so i did that inside the loop it continue to give the same one, but if you use another command it return the real one, what do you think about that |
Signed-off-by: Lumouille <[email protected]>
if you can get that to work then that would be fine |
Signed-off-by: Lumouille <[email protected]>
Signed-off-by: Lumouille <[email protected]>
is this enough ? task = asyncio.create_task(
(
self.coro(*args, **kwargs)
if self.overlap is True
else run_with_semaphore()
),
name=f"pycord-loop-{self.coro.__name__}-{self._current_loop}",
)
task.add_done_callback(self._tasks.remove)
self._tasks.append(task) |
Signed-off-by: Lumouille <[email protected]>
Signed-off-by: Lumouille <[email protected]>
should be ready for review |
Summary
Information
examples, ...).
Checklist
type: ignore
comments were used, a comment is also left explaining why.