File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,19 @@ def cb(arg):
205
205
self .loop .run_forever ()
206
206
self .assertEqual (calls , ['a' ])
207
207
208
+ def test_call_later_rounding (self ):
209
+ # Refs #233, call_later() and call_at() shouldn't call cb early
210
+
211
+ def cb ():
212
+ self .loop .stop ()
213
+
214
+ for i in range (8 ):
215
+ self .loop .call_later (0.06 + 0.01 , cb ) # 0.06999999999999999
216
+ started = int (round (self .loop .time () * 1000 ))
217
+ self .loop .run_forever ()
218
+ finished = int (round (self .loop .time () * 1000 ))
219
+ self .assertGreaterEqual (finished - started , 70 )
220
+
208
221
def test_call_at (self ):
209
222
if os .environ .get ('TRAVIS_OS_NAME' ):
210
223
# Time seems to be really unpredictable on Travis.
Original file line number Diff line number Diff line change @@ -1291,7 +1291,7 @@ cdef class Loop:
1291
1291
# infinity for a Python application.
1292
1292
delay = 3600 * 24 * 365 * 100
1293
1293
1294
- when = < uint64_t> (delay * 1000 )
1294
+ when = < uint64_t> round (delay * 1000 )
1295
1295
if not args:
1296
1296
args = None
1297
1297
if when == 0 :
You can’t perform that action at this time.
0 commit comments