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