Skip to content

Commit f5ae669

Browse files
committed
uasyncio.core: Remove heapq aggregate structure workaround.
1 parent d9e72f1 commit f5ae669

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

uasyncio.core/uasyncio/core.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class EventLoop:
1414

1515
def __init__(self):
1616
self.q = []
17-
self.cnt = 0
1817

1918
def time(self):
2019
return time.ticks_ms()
@@ -34,12 +33,9 @@ def call_later_ms(self, delay, callback, *args):
3433
self.call_at(time.ticks_add(self.time(), delay), callback, *args)
3534

3635
def call_at(self, time, callback, *args):
37-
# Including self.cnt is a workaround per heapq docs
3836
if __debug__:
39-
log.debug("Scheduling %s", (time, self.cnt, callback, args))
40-
heapq.heappush(self.q, (time, self.cnt, callback, args), True)
41-
# print(self.q)
42-
self.cnt += 1
37+
log.debug("Scheduling %s", (time, callback, args))
38+
heapq.heappush(self.q, (time, callback, args), True)
4339

4440
def wait(self, delay):
4541
# Default wait implementation, to be overriden in subclasses
@@ -51,9 +47,9 @@ def wait(self, delay):
5147
def run_forever(self):
5248
while True:
5349
if self.q:
54-
t, cnt, cb, args = heapq.heappop(self.q, True)
50+
t, cb, args = heapq.heappop(self.q, True)
5551
if __debug__:
56-
log.debug("Next coroutine to run: %s", (t, cnt, cb, args))
52+
log.debug("Next coroutine to run: %s", (t, cb, args))
5753
# __main__.mem_info()
5854
tnow = self.time()
5955
delay = time.ticks_diff(t, tnow)

0 commit comments

Comments
 (0)