File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -465,9 +465,9 @@ async def run_inner() -> None:
465
465
global quit_event
466
466
loop = typing .cast (SlintEventLoop , asyncio .get_event_loop ())
467
467
468
- tasks : typing . List [ asyncio .Task [ typing . Any ]] = [
469
- asyncio . ensure_future ( quit_event . wait (), loop = loop )
470
- ]
468
+ quit_task = asyncio .ensure_future ( quit_event . wait (), loop = loop )
469
+
470
+ tasks : typing . List [ asyncio . Task [ typing . Any ]] = [ quit_task ]
471
471
472
472
main_task = None
473
473
if main_coro :
@@ -478,6 +478,8 @@ async def run_inner() -> None:
478
478
479
479
if main_task is not None and main_task in done :
480
480
main_task .result () # propagate exception if thrown
481
+ if quit_task in pending :
482
+ await quit_event .wait ()
481
483
482
484
global quit_event
483
485
quit_event = asyncio .Event ()
Original file line number Diff line number Diff line change 12
12
import pytest
13
13
import sys
14
14
import platform
15
+ from datetime import timedelta
15
16
16
17
17
18
def test_async_basic () -> None :
@@ -181,6 +182,23 @@ async def never_quit() -> None:
181
182
pytest .fail ("Should not throw a run-time error" )
182
183
183
184
185
+ def test_loop_continues_when_main_coro_finished () -> None :
186
+ async def quit_later (quit_event : asyncio .Event ) -> None :
187
+ await quit_event .wait ()
188
+ slint .quit_event_loop ()
189
+
190
+ async def simple (quit_event : asyncio .Event ) -> None :
191
+ loop = asyncio .get_event_loop ()
192
+ loop .create_task (quit_later (quit_event ))
193
+
194
+ quit_event = asyncio .Event ()
195
+ slint .Timer .single_shot (
196
+ duration = timedelta (milliseconds = 100 ), callback = lambda : quit_event .set ()
197
+ )
198
+ slint .run_event_loop (simple (quit_event ))
199
+ assert quit_event .is_set ()
200
+
201
+
184
202
@pytest .mark .skipif (platform .system () == "Windows" , reason = "pipes aren't supported yet" )
185
203
def test_subprocess () -> None :
186
204
async def launch_process (exception_check : typing .List [Exception ]) -> None :
You can’t perform that action at this time.
0 commit comments