Commit Graph
53 Commits
Author SHA1 Message Date
iDutchy 34f6c5db10 looks like I changed stuff? 2021-06-25 20:29:27 -05:00
Steve CandRapptz a9dba2753f [tasks] Move the Loop's sleep to be before exit conditions
This change makes it more so that `Loop.stop()` gracefully makes the
current iteration the final one, by waiting AND THEN returning.
The current implementation is closer to `cancel`, while also not.

I encountered this because I was trying to run a
`@tasks.loop(count=1)`, and inside it I print some text and change the
interval, and in an `after_loop`, I restart the loop.

Without this change, it immediately floods my console, due to
not waiting before executing `after_loop`.
2021-05-01 10:28:00 -04:00
Nadir ChowdhuryandGitHub 89456022cf Add __all__ to remaining modules 2021-04-07 02:30:32 -04:00
Rapptz 9d39b135f4 Modernize code to use f-strings
This also removes the encoding on the top, since Python 3 does it by
default. It also changes some methods to use `yield from`.
2021-04-04 07:03:53 -04:00
Sebastian LawandGitHub f7a4bef4ff [tasks] remove redundant condition in Loop.next_iteration
self._task is only None if the Loop has never been started before, 
which means None should be returned always, regardless of how
many seconds was passed into the constructor

this didn't break anything before because self._next_iteration will
be None as well if self._task is None.
2021-02-28 23:54:44 -05:00
Nadir ChowdhuryandGitHub 63ec23bac2 Code optimisations and refactoring via Sourcery 2021-02-24 21:26:51 -05:00
Sebastian LawandGitHub ceab8ff638 [tasks] make __call__ actually appear in the docs 2021-02-21 07:19:10 -05:00
Nihaal SanghaandGitHub 69bdc3a184 Change copyright year to present 2021-01-15 05:28:11 -05:00
Rapptz 6515f33978 [tasks] Fix a typo in documentation 2020-12-14 22:18:40 -05:00
Rapptz 0216db0c0a [tasks] Add support for manually calling the wrapped coroutine 2020-12-14 22:11:37 -05:00
Rapptz ccdf4c4ad6 [tasks] Lazily fetch event loop if one isn't provided
Fixes #5808
2020-09-10 00:00:58 -04:00
JoshandGitHub 6baacb2c23 [tasks] Don't update _next_iteration on retry 2020-08-28 23:12:07 -04:00
Dan HessandGitHub fc951873a1 [tasks] Remove HTTPException as an exception to silently continue for 2020-08-05 03:09:04 -04:00
Rapptz b8154e365f Rewrite gateway to use aiohttp instead of websockets 2020-07-25 09:59:38 -04:00
JamesandRapptz 61216112d0 Add a licence and encoding declaration to missing files 2020-07-08 23:01:00 -04:00
JoshandGitHub 6b5be39cd2 [tasks] Fix issue with default error handler in class context 2020-06-28 03:53:29 -04:00
Steve CandRapptz 4b3a7fbe16 [tasks] Allow Loop.cancel in Loop.before_loop
Task cancel raises on the next awaited coro, so I've added this 0-sleep "hack"

I'm internally debating if leaving the comment there, but I'm sure it would confuse the uninformed of this trick.
2020-05-10 17:00:23 -04:00
Steve CandRapptz 0fd5eca0d5 [tasks] Fix tasks decorators being discarded
At this moment, when a task seems to be first loaded, it immediately throws away the decorators you give it, and just generates a new instance of itself.

In your cog's `__init__`, once you do `self.my_task.start()`, the Loop is remade when it gets to `self.my_task` before executing the `start` function. The original Loop that the cog starts with is where the decorated values are. This fixes that.
2020-05-07 02:30:24 -04:00
Rapptz 540a88b762 [tasks] Replace stack-based implementation with a cleaner one. 2020-04-14 04:56:52 -04:00
Rapptz d5211fb327 [tasks] Create different Loop objects for different instances
Fixes #2294
2020-04-14 04:35:49 -04:00
Josh BandRapptz 20854de080 Allow for optional custom error handler in tasks extension 2020-04-04 03:11:25 -04:00
EpicandRapptz 18c52671a9 Remove extra to in tasks docs 2020-04-04 03:09:21 -04:00
JamesandRapptz 6a30f2749f [tasks] Add is_running property to Loop 2020-04-04 03:02:10 -04:00
Josh BandRapptz d0a1956be9 Improve usability of utils.sleep_until
Fix issue where sleeping for an extended period on python 3.5
would cause an exception

Add sleep_until to API docs

Add result argument to sleep_until
2020-01-21 20:28:14 -05:00
Rapptz 02397306b2 Drop superfluous zero in version related changes in the documentation 2020-01-21 03:47:56 -05:00
Rapptz 3149f15165 [tasks] Use new sleep_until util instead of internal function 2020-01-21 03:21:22 -05:00
Josh BandRapptz d7e925eb89 [tasks] Fix issue with next_iteration when task overruns time allotted 2020-01-21 03:18:25 -05:00
Josh BandRapptz a0b3e61b51 [tasks] Add Loop.next_iteration property 2020-01-20 07:22:21 -05:00
Rapptz e1a237a0d3 Revert "[tasks] Add Loop.exception for more reliable exception retrieval."
This reverts commit 7a8c9e66d9.
2019-11-19 21:59:39 -05:00
Rapptz 071c5b89e0 Revert "[tasks] Add support for explicit time parameter when running."
This reverts commit 9f822a1e6d.
2019-11-19 21:59:27 -05:00
mathsman5133andRapptz 7f65d9a8b1 [tasks] Add support for passing an argument list of exceptions. 2019-09-10 21:10:59 -04:00
Rapptz 9f822a1e6d [tasks] Add support for explicit time parameter when running.
Fixes #2159
2019-08-11 18:57:49 -04:00
Rapptz 7a8c9e66d9 [tasks] Add Loop.exception for more reliable exception retrieval. 2019-07-27 23:07:48 -04:00
NihaalandRapptz 9687740217 [tasks] Removed Returns from decorator docstring 2019-06-29 19:15:06 -04:00
NCPlayzandRapptz 3c9bcc2851 Improve documentation 2019-06-07 19:27:46 -04:00
SuhailandRapptz db9a293f14 [tasks] Add version added note to Loop.change_interval 2019-05-19 19:17:28 -04:00
Suhail6inklingandDanny aadb6953ff [tasks] Add way to change interval at run-time
PR: #2162 
Fixes: #2158
2019-05-17 18:25:21 -04:00
Rapptz 6bc9d7c01a [tasks] Add indicator for internal task failure
Fixes #2151
2019-05-13 22:10:38 -04:00
Rapptz a4a362b4c7 [tasks] Log exception when something failed to logging. 2019-05-13 22:08:31 -04:00
SnowyLumaandRapptz 859ee751f9 [tasks] Return coro from before and after decorators 2019-05-13 20:29:07 -04:00
Rapptz 49a7e58d17 [tasks] Keep retrying before gracefully exiting. 2019-05-12 01:31:09 -04:00
Rapptz 4eead39b3c [tasks] Add Loop.stop to gracefully stop a task.
Updated docs will follow shortly.
2019-05-12 01:04:24 -04:00
Rapptz bcdecd4e07 [tasks] Reset iteration count when loop terminates. 2019-05-12 00:49:19 -04:00
Steve CandGitHub 8f111c521c Fix typo in Loop.restart documentation 2019-05-10 18:44:07 -04:00
Rapptz 47808a7e96 [tasks] Add Loop.restart
This implementation waits until the task is done before starting it
again.

Closes #2075
2019-05-10 18:37:37 -04:00
Rapptz 91e00d8426 [tasks] Add way to query cancellation state for Loop.after_loop
Fixes #2121
2019-04-30 01:45:15 -04:00
Rapptz 55e3e242ff [tasks] Remove support for awaitables due to gotchas.
Fixes #2079
2019-04-29 23:34:20 -04:00
DannyandGitHub 2a301a4eb4 [tasks] Fix assignment of tuple when appending 2019-04-15 14:49:52 -04:00
Steve CandRapptz ac2cda1ffc [tasks] set internal task to None after canceling 2019-04-12 20:56:40 -04:00
Rapptz e46842a7cd [tasks] Add before_loop and after_loop decorators 2019-04-12 04:08:42 -04:00