Skip to content

Commit e2403bd

Browse files
author
Paul Sokolovsky
committed
asyncio: Make run_forever() actually run forever.
1 parent 25bcef1 commit e2403bd

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

asyncio/asyncio.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ def wait(self, delay):
3939
time.sleep(delay)
4040

4141
def run_forever(self):
42-
while self.q:
43-
# t, cnt, cb, args = self.q.pop(0)
44-
t, cnt, cb, args = heapq.heappop(self.q)
45-
tnow = self.time()
46-
delay = t - tnow
47-
if delay > 0:
48-
self.wait(delay)
42+
while True:
43+
if self.q:
44+
t, cnt, cb, args = heapq.heappop(self.q)
45+
tnow = self.time()
46+
delay = t - tnow
47+
if delay > 0:
48+
self.wait(delay)
49+
else:
50+
self.wait(-1)
51+
# Assuming IO completion scheduled some tasks
52+
continue
4953
if callable(cb):
5054
cb(*args)
5155
else:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy