Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
also clean name from previous task list
  • Loading branch information
dlashua committed Nov 30, 2020
commit a90447eafab4fac4e2934ce6967aec2d0362e9ef
5 changes: 5 additions & 0 deletions custom_components/pyscript/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ async def task_unique(name, kill_me=False):
except asyncio.CancelledError:
pass
if curr_task in cls.our_tasks:
if name in cls.unique_name2task:
task = cls.unique_name2task[name]
if task in cls.unique_task2name:
if name in cls.unique_task2name[task]:
cls.unique_task2name[task].remove(name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more efficient to use a set, in which case the last two lines can just be a single-line discard (which is a no-op if not present)

cls.unique_name2task[name] = curr_task
if curr_task not in cls.unique_task2name:
cls.unique_task2name[curr_task] = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be set() instead of []

Expand Down