Skip to content

Commit 84690e8

Browse files
author
Your Name
committed
#437: Fix race-condition beween multiple calls to stop_output_task()
1 parent 765d7e2 commit 84690e8

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

cecli/io.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,8 +1046,9 @@ async def stop_input_task(self):
10461046
input_task = self.input_task
10471047
self.input_task = None
10481048
try:
1049-
input_task.cancel()
1050-
await input_task
1049+
if input_task:
1050+
input_task.cancel()
1051+
await input_task
10511052
except (
10521053
asyncio.CancelledError,
10531054
Exception,
@@ -1064,8 +1065,9 @@ async def stop_output_task(self):
10641065
output_task = self.output_task
10651066
self.output_task = None
10661067
try:
1067-
output_task.cancel()
1068-
await output_task
1068+
if output_task:
1069+
output_task.cancel()
1070+
await output_task
10691071
except (
10701072
asyncio.CancelledError,
10711073
EOFError,

0 commit comments

Comments
 (0)