aboutsummaryrefslogtreecommitdiffstats
path: root/slack/task.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2022-10-24 21:59:31 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:52 +0100
commitee9d976ff8d8910c091d1554dfa62ab28ad67509 (patch)
tree79cae5e252be07e11fd2d735b9c7fb37f91830d4 /slack/task.py
parente3bc88120e071eac8fabb5b02d7b509488d563e2 (diff)
downloadwee-slack-ee9d976ff8d8910c091d1554dfa62ab28ad67509.tar.gz
Rename globals to G
Diffstat (limited to 'slack/task.py')
-rw-r--r--slack/task.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/slack/task.py b/slack/task.py
index e976866..d9ba1cb 100644
--- a/slack/task.py
+++ b/slack/task.py
@@ -3,7 +3,7 @@ from __future__ import annotations
from typing import Any, Awaitable, Coroutine, Generator, Tuple, TypeVar
from uuid import uuid4
-import globals
+import globals as G
import weechat
T = TypeVar("T")
@@ -33,7 +33,7 @@ class Task(Future[T]):
def weechat_task_cb(data: str, *args: Any) -> int:
- task = globals.active_tasks.pop(data)
+ task = G.active_tasks.pop(data)
task_runner(task, args)
return weechat.WEECHAT_RC_OK
@@ -42,26 +42,26 @@ def task_runner(task: Task[Any], response: Any):
while True:
try:
future = task.coroutine.send(response)
- if future.id in globals.active_responses:
- response = globals.active_responses.pop(future.id)
+ if future.id in G.active_responses:
+ response = G.active_responses.pop(future.id)
else:
- if future.id in globals.active_tasks:
+ if future.id in G.active_tasks:
raise Exception(
- f"future.id in active_tasks, {future.id}, {globals.active_tasks}"
+ f"future.id in active_tasks, {future.id}, {G.active_tasks}"
)
- globals.active_tasks[future.id] = task
+ G.active_tasks[future.id] = task
break
except StopIteration as e:
- if task.id in globals.active_tasks:
- task = globals.active_tasks.pop(task.id)
+ if task.id in G.active_tasks:
+ task = G.active_tasks.pop(task.id)
response = e.value
else:
- if task.id in globals.active_responses:
+ if task.id in G.active_responses:
raise Exception( # pylint: disable=raise-missing-from
- f"task.id in active_responses, {task.id}, {globals.active_responses}"
+ f"task.id in active_responses, {task.id}, {G.active_responses}"
)
if not task.final:
- globals.active_responses[task.id] = e.value
+ G.active_responses[task.id] = e.value
break