Skip to content

Commit

Permalink
RootTask: Guard against unsynchronized access to RootTask.children
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfstr committed Sep 27, 2023
1 parent b4159a0 commit 16f419d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/crystal/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ def append_child(self, child: Task, *, already_complete_ok: bool=False) -> None:
def finish(self) -> None:
"""
Marks this task as completed.
Threadsafe.
"""
# Mark as complete immediately, because caller may check this task's complete status
self._complete = True
Expand Down Expand Up @@ -1310,6 +1309,12 @@ def __init__(self):
super().__init__(title='ROOT')
self.subtitle = 'Running'

@property # type: ignore[misc]
@fg_affinity # force any access to synchronize with foreground thread
@overrides
def children(self) -> List[Task]:
return super().children

@overrides
def append_child(self, child: Task, *args, **kwargs) -> None:
"""
Expand Down

0 comments on commit 16f419d

Please sign in to comment.