File tree 1 file changed +24
-4
lines changed
1 file changed +24
-4
lines changed Original file line number Diff line number Diff line change 8
8
import pytest
9
9
10
10
from mmpy_bot import schedule
11
+ from mmpy_bot .threadpool import ThreadPool
11
12
12
13
13
14
def test_once ():
@@ -78,11 +79,21 @@ def job(modifiable_arg: Dict):
78
79
79
80
start = time .time ()
80
81
end = start + 3.5 # We want to wait just over 3 seconds
82
+
83
+ pool = ThreadPool (num_workers = 10 )
84
+
85
+ pool .start_scheduler_thread (trigger_period = 1 ) # in seconds
86
+
87
+ # Start the pool thread
88
+ pool .start ()
89
+
81
90
while time .time () < end :
82
- # Launch job and wait one second
83
- schedule .run_pending ()
91
+ # Wait until we reach our 3+ second deadline
84
92
time .sleep (1 )
85
93
94
+ # Stop the pool and scheduler loop
95
+ pool .stop ()
96
+
86
97
# Stop all scheduled jobs
87
98
schedule .clear ()
88
99
# Nothing should happen from this point, even if we sleep another while
@@ -116,11 +127,20 @@ def job(path: str, modifiable_arg: Dict):
116
127
117
128
start = time .time ()
118
129
end = start + 3.5 # We want to wait just over 3 seconds
130
+ pool = ThreadPool (num_workers = 10 )
131
+
132
+ pool .start_scheduler_thread (trigger_period = 1 ) # in seconds
133
+
134
+ # Start the pool thread
135
+ pool .start ()
136
+
119
137
while time .time () < end :
120
- # Launch job and wait one second
121
- schedule .run_pending ()
138
+ # Wait until we reach our 3+ second deadline
122
139
time .sleep (1 )
123
140
141
+ # Stop the pool and scheduler loop
142
+ pool .stop ()
143
+
124
144
# Stop all scheduled jobs
125
145
schedule .clear ()
126
146
# Nothing should happen from this point, even if we sleep another while
You can’t perform that action at this time.
0 commit comments