diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-01-31 20:07:08 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:53 +0100 |
commit | 54c85b18e036d29b7d0e2ca4d5543b37e4fc2f16 (patch) | |
tree | 56ccda139a072e1149d5d46c9f6c8ef6232c39e5 | |
parent | 72c12c66fa8dbdd94e6e31d0a96d41ae45491930 (diff) | |
download | wee-slack-54c85b18e036d29b7d0e2ca4d5543b37e4fc2f16.tar.gz |
Sleep for 1 ms if 0 ms is specified
asyncio.sleep(0) is used to move the task to the back of the event loop.
This sleep can be used for the same, however if 0 is specified, WeeChat
never calls the callback. This means that the task will silently not
continue which is very bad, so make it sleep for 1 ms instead, which is
practically the same.
-rw-r--r-- | slack/task.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/slack/task.py b/slack/task.py index e61ddb6..3c21415 100644 --- a/slack/task.py +++ b/slack/task.py @@ -270,7 +270,6 @@ async def gather( async def sleep(milliseconds: int): future = FutureTimer() - weechat.hook_timer( - milliseconds, 0, 1, get_callback_name(weechat_task_cb), future.id - ) + sleep_ms = milliseconds if milliseconds > 0 else 1 + weechat.hook_timer(sleep_ms, 0, 1, get_callback_name(weechat_task_cb), future.id) return await future |