-
-
Notifications
You must be signed in to change notification settings - Fork 481
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 <144063653+Lumabots@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
…t: 'overlap' Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
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 <144063653+Lumabots@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
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 <plun1331@gmail.com> Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Co-authored-by: plun1331 <plun1331@gmail.com> Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
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 <144063653+Lumabots@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
fixed |
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
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.
Pull Request Overview
This PR adds optional overlap support to the loop decorator and Loop class to allow concurrent executions of loop iterations. Instead of waiting for each iteration to complete before starting the next one, users can now enable overlapping executions.
Key changes:
- Adds
overlap
parameter that acceptsFalse
(default),True
, or an integer for controlled concurrency - Uses asyncio tasks and semaphores to manage concurrent executions
- Adds proper cleanup of running tasks when the loop is cancelled
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
discord/ext/tasks/init.py | Implements overlap functionality with task management, semaphore controls, and concurrent execution logic |
CHANGELOG.md | Documents the new overlap feature in version 2.7 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
b55c125
to
82659b2
Compare
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.
Could that potentially clutch with #2645?
Co-authored-by: DA344 <108473820+DA-344@users.noreply.github.com> Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Not anymore |
No description provided.