Skip to content

Commit

Permalink
Fix exeptions caused by closing the event loop before all tasks were …
Browse files Browse the repository at this point in the history
…cancelled
  • Loading branch information
Ketok4321 committed Aug 18, 2023
1 parent 07ed372 commit 0052e18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/speedtest_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def run(self):
event_loop = asyncio.new_event_loop()

event_loop.run_until_complete(self.run_async())

event_loop.close()

async def run_async(self):
Expand All @@ -29,6 +30,13 @@ async def run_async(self):
break

await asyncio.sleep(0)

for task in asyncio.all_tasks():
task.cancel()
try:
await task
except asyncio.CancelledError:
pass

async def do_run(self):
try:
Expand Down
2 changes: 1 addition & 1 deletion src/ui/views/test.blp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ template $TestView : Box {
Label title {
label: bind template.server;
margin-top: 8;
styles [ "title-2" ]
styles [ "title-3" ]
}

Box {
Expand Down

0 comments on commit 0052e18

Please sign in to comment.