File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -62,9 +62,9 @@ def runner():
62
62
def test_all_tasks_different_thread (self ) -> None :
63
63
loop = None
64
64
started = threading .Event ()
65
-
65
+ done = threading . Event () # used for main task not finishing early
66
66
async def coro ():
67
- await asyncio .sleep ( 0.01 )
67
+ await asyncio .Future ( )
68
68
69
69
lock = threading .Lock ()
70
70
tasks = set ()
@@ -77,6 +77,7 @@ async def main():
77
77
with lock :
78
78
asyncio .create_task (coro ())
79
79
tasks = self .all_tasks (loop )
80
+ done .wait ()
80
81
81
82
runner = threading .Thread (target = lambda : asyncio .run (main ()))
82
83
@@ -86,11 +87,14 @@ def check():
86
87
self .assertSetEqual (tasks & self .all_tasks (loop ), tasks )
87
88
88
89
threads = [threading .Thread (target = check ) for _ in range (10 )]
89
- threads . append ( runner )
90
+ runner . start ( )
90
91
91
92
with threading_helper .start_threads (threads ):
92
93
pass
93
94
95
+ done .set ()
96
+ runner .join ()
97
+
94
98
def test_run_coroutine_threadsafe (self ) -> None :
95
99
results = []
96
100
You can’t perform that action at this time.
0 commit comments