File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change 11import threading
2- import time
32
43import pytest
54
@@ -40,15 +39,15 @@ def _test_ack(
4039
4140 def do_ack () -> None :
4241 start .wait ()
43- time .sleep (0.001 )
4442 with cond :
4543 handle .ack = ack # type: ignore[assignment]
4644 cond .notify_all ()
4745 thread = threading .Thread (target = do_ack )
4846 thread .start ()
4947
50- start .set ()
51- assert handle .wait_for_ack (timeout = 0.01 ) == ack
48+ with cond :
49+ start .set ()
50+ assert handle .wait_for_ack (timeout = 0.01 ) == ack
5251
5352 thread .join ()
5453
@@ -65,16 +64,16 @@ def _test_exc(
6564
6665 def do_ack () -> None :
6766 start .wait ()
68- time .sleep (0.001 )
6967 with cond :
7068 handle .exc = ValueError ("TEST" )
7169 cond .notify_all ()
7270 thread = threading .Thread (target = do_ack )
7371 thread .start ()
7472
75- start .set ()
76- with pytest .raises (ValueError , match = "TEST" ):
77- handle .wait_for_ack (timeout = 0.01 )
73+ with cond :
74+ start .set ()
75+ with pytest .raises (ValueError , match = "TEST" ):
76+ handle .wait_for_ack (timeout = 0.01 )
7877
7978 thread .join ()
8079
You can’t perform that action at this time.
0 commit comments