Skip to content

Commit 72a90a0

Browse files
committed
uasyncio.core: test_full_wait.py: Make easier to debug.
1 parent 85c82e7 commit 72a90a0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

uasyncio.core/test_full_wait.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Test that coros scheduled to run at some time don't run prematurely
22
# in case of I/O completion before that.
33
import uasyncio.core as uasyncio
4+
import logging
5+
logging.basicConfig(level=logging.DEBUG)
6+
#uasyncio.set_debug(True)
7+
48

59
class MockEventLoop(uasyncio.EventLoop):
610

@@ -16,15 +20,25 @@ def pass_time(self, delta):
1620
self.t += delta
1721

1822
def wait(self, delay):
23+
#print("%d: wait(%d)" % (self.t, delay))
1924
self.pass_time(100)
25+
2026
if self.t == 100:
21-
self.call_soon(lambda: self.msgs.append("I should be run first, time: %s" % self.time()))
27+
def cb_1st():
28+
self.msgs.append("I should be run first, time: %s" % self.time())
29+
self.call_soon(cb_1st)
30+
2231
if self.t == 1000:
2332
raise StopIteration
2433

2534

2635
loop = MockEventLoop()
27-
loop.call_later_ms(500, lambda: loop.msgs.append("I should be run second, time: %s" % loop.time()))
36+
37+
def cb_2nd():
38+
loop.msgs.append("I should be run second, time: %s" % loop.time())
39+
40+
loop.call_later_ms(500, cb_2nd)
41+
2842
try:
2943
loop.run_forever()
3044
except StopIteration:
@@ -33,4 +47,4 @@ def wait(self, delay):
3347
print(loop.msgs)
3448
# .wait() is now called on each loop iteration, and for our mock case, it means that
3549
# at the time of running, self.time() will be skewed by 100 virtual time units.
36-
assert loop.msgs == ['I should be run first, time: 200', 'I should be run second, time: 600']
50+
assert loop.msgs == ['I should be run first, time: 200', 'I should be run second, time: 600'], str(loop.msgs)

0 commit comments

Comments
 (0)