File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,20 @@ def cb(arg):
171
171
self .loop .run_forever ()
172
172
self .assertEqual (calls , ['a' ])
173
173
174
+ def test_call_later_rounding (self ):
175
+ # Refs #233, call_later() and call_at() shouldn't call cb early
176
+
177
+ def cb ():
178
+ self .loop .stop ()
179
+
180
+ for i in range (8 ):
181
+ self .loop .call_later (0.06 + 0.01 , cb ) # 0.06999999999999999
182
+ started = time .monotonic ()
183
+ self .loop .run_forever ()
184
+ finished = time .monotonic ()
185
+ self .assertGreaterEqual (int (round ((finished - started ) * 1000 )),
186
+ 70 )
187
+
174
188
def test_call_at (self ):
175
189
if os .environ .get ('TRAVIS_OS_NAME' ):
176
190
# Time seems to be really unpredictable on Travis.
Original file line number Diff line number Diff line change @@ -1254,7 +1254,7 @@ cdef class Loop:
1254
1254
# infinity for a Python application.
1255
1255
delay = 3600 * 24 * 365 * 100
1256
1256
1257
- when = < uint64_t> (delay * 1000 )
1257
+ when = < uint64_t> round (delay * 1000 )
1258
1258
if not args:
1259
1259
args = None
1260
1260
if when == 0 :
You can’t perform that action at this time.
0 commit comments