Skip to content

change repeaer to reaper #116

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

Merged
merged 1 commit into from
Dec 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions custom_components/pyscript/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Function:
# task id of the task that cancels and waits for other tasks,
# and also awaits on coros
#
task_repeaer = None
task_reaper = None

def __init__(self):
"""Warn on Function instantiation."""
Expand Down Expand Up @@ -108,17 +108,17 @@ async def task_reaper(reaper_q):
except Exception:
_LOGGER.error("task_reaper: got exception %s", traceback.format_exc(-1))

if not cls.task_repeaer:
if not cls.task_reaper:
cls.task_reaper_q = asyncio.Queue(0)
cls.task_repeaer = Function.create_task(task_reaper(cls.task_reaper_q))
cls.task_reaper = Function.create_task(task_reaper(cls.task_reaper_q))

@classmethod
async def reaper_stop(cls):
"""Tell the reaper task to exit by sending a special task None."""
if cls.task_repeaer:
if cls.task_reaper:
cls.task_reaper_q.put_nowait(["exit"])
await cls.task_repeaer
cls.task_repeaer = None
await cls.task_reaper
cls.task_reaper = None
cls.task_reaper_q = None

@classmethod
Expand Down Expand Up @@ -180,7 +180,7 @@ async def task_unique(name, kill_me=False):
if task != curr_task:
#
# it seems we can't cancel ourselves, so we
# tell the repeaer task to cancel us
# tell the reaper task to cancel us
#
Function.reaper_cancel(curr_task)
# wait to be canceled
Expand Down