Commit Graph

60 Commits

Author SHA1 Message Date
a2a7b0f076 [tasks] Improve typing parity 2021-08-27 17:18:15 -04:00
ea2d972666 Make global log variable in modules private 2021-08-22 02:33:51 -04:00
76c9e390f1 remove repeat 'to' in Task.restart doc 2021-06-27 23:42:43 -04:00
42a538edda [tasks] Replace None check with MISSING check in task loop 2021-05-15 02:10:00 -04:00
ef22178dee [tasks] Type hint the tasks extension 2021-05-12 06:31:40 -04:00
f5727ff0d0 [tasks] fix regular task loops 2021-05-10 20:25:16 -04:00
8bc489dba8 [tasks] Add support for explicit time parameter 2021-05-09 23:27:43 -04:00
ef9bb79e91 [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-04-16 22:35:18 -04:00
99fc950510 Use f-strings in more places that were missed. 2021-04-08 06:02:47 -04:00
89456022cf Add __all__ to remaining modules 2021-04-07 02:30:32 -04:00
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
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
63ec23bac2 Code optimisations and refactoring via Sourcery 2021-02-24 21:26:51 -05:00
ceab8ff638 [tasks] make __call__ actually appear in the docs 2021-02-21 07:19:10 -05:00
69bdc3a184 Change copyright year to present 2021-01-15 05:28:11 -05:00
6515f33978 [tasks] Fix a typo in documentation 2020-12-14 22:18:40 -05:00
0216db0c0a [tasks] Add support for manually calling the wrapped coroutine 2020-12-14 22:11:37 -05:00
ccdf4c4ad6 [tasks] Lazily fetch event loop if one isn't provided
Fixes #5808
2020-09-10 00:00:58 -04:00
6baacb2c23 [tasks] Don't update _next_iteration on retry 2020-08-28 23:12:07 -04:00
fc951873a1 [tasks] Remove HTTPException as an exception to silently continue for 2020-08-05 03:09:04 -04:00
b8154e365f Rewrite gateway to use aiohttp instead of websockets 2020-07-25 09:59:38 -04:00
61216112d0 Add a licence and encoding declaration to missing files 2020-07-08 23:01:00 -04:00
6b5be39cd2 [tasks] Fix issue with default error handler in class context 2020-06-28 03:53:29 -04:00
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
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
540a88b762 [tasks] Replace stack-based implementation with a cleaner one. 2020-04-14 04:56:52 -04:00
d5211fb327 [tasks] Create different Loop objects for different instances
Fixes #2294
2020-04-14 04:35:49 -04:00
20854de080 Allow for optional custom error handler in tasks extension 2020-04-04 03:11:25 -04:00
18c52671a9 Remove extra to in tasks docs 2020-04-04 03:09:21 -04:00
6a30f2749f [tasks] Add is_running property to Loop 2020-04-04 03:02:10 -04:00
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
02397306b2 Drop superfluous zero in version related changes in the documentation 2020-01-21 03:47:56 -05:00
3149f15165 [tasks] Use new sleep_until util instead of internal function 2020-01-21 03:21:22 -05:00
d7e925eb89 [tasks] Fix issue with next_iteration when task overruns time allotted 2020-01-21 03:18:25 -05:00
a0b3e61b51 [tasks] Add Loop.next_iteration property 2020-01-20 07:22:21 -05:00
e1a237a0d3 Revert "[tasks] Add Loop.exception for more reliable exception retrieval."
This reverts commit 7a8c9e66d9.
2019-11-19 21:59:39 -05:00
071c5b89e0 Revert "[tasks] Add support for explicit time parameter when running."
This reverts commit 9f822a1e6d.
2019-11-19 21:59:27 -05:00
7f65d9a8b1 [tasks] Add support for passing an argument list of exceptions. 2019-09-10 21:10:59 -04:00
9f822a1e6d [tasks] Add support for explicit time parameter when running.
Fixes #2159
2019-08-11 18:57:49 -04:00
7a8c9e66d9 [tasks] Add Loop.exception for more reliable exception retrieval. 2019-07-27 23:07:48 -04:00
9687740217 [tasks] Removed Returns from decorator docstring 2019-06-29 19:15:06 -04:00
3c9bcc2851 Improve documentation 2019-06-07 19:27:46 -04:00
db9a293f14 [tasks] Add version added note to Loop.change_interval 2019-05-19 19:17:28 -04:00
aadb6953ff [tasks] Add way to change interval at run-time
PR: #2162 
Fixes: #2158
2019-05-17 18:25:21 -04:00
6bc9d7c01a [tasks] Add indicator for internal task failure
Fixes #2151
2019-05-13 22:10:38 -04:00
a4a362b4c7 [tasks] Log exception when something failed to logging. 2019-05-13 22:08:31 -04:00
859ee751f9 [tasks] Return coro from before and after decorators 2019-05-13 20:29:07 -04:00
49a7e58d17 [tasks] Keep retrying before gracefully exiting. 2019-05-12 01:31:09 -04:00
4eead39b3c [tasks] Add Loop.stop to gracefully stop a task.
Updated docs will follow shortly.
2019-05-12 01:04:24 -04:00
bcdecd4e07 [tasks] Reset iteration count when loop terminates. 2019-05-12 00:49:19 -04:00