No connection CPU hog fix
- the previous fix was incomplete, it shouldn't consume excessive resources now when there are no connections
This commit is contained in:
parent
01c8f3b66d
commit
d6df4470e1
|
@ -398,6 +398,8 @@ def loop(timeout=30.0, use_poll=False, map=None, count=None,
|
||||||
poller=None):
|
poller=None):
|
||||||
if map is None:
|
if map is None:
|
||||||
map = socket_map
|
map = socket_map
|
||||||
|
if count is None:
|
||||||
|
count = True
|
||||||
# code which grants backward compatibility with "use_poll"
|
# code which grants backward compatibility with "use_poll"
|
||||||
# argument which should no longer be used in favor of
|
# argument which should no longer be used in favor of
|
||||||
# "poller"
|
# "poller"
|
||||||
|
@ -414,27 +416,20 @@ def loop(timeout=30.0, use_poll=False, map=None, count=None,
|
||||||
elif hasattr(select, 'select'):
|
elif hasattr(select, 'select'):
|
||||||
poller = select_poller
|
poller = select_poller
|
||||||
|
|
||||||
if count is None:
|
if timeout == 0:
|
||||||
while map:
|
deadline = 0
|
||||||
# fill buckets first
|
|
||||||
update_sent()
|
|
||||||
update_received()
|
|
||||||
# then poll
|
|
||||||
poller(timeout, map)
|
|
||||||
else:
|
else:
|
||||||
if timeout == 0:
|
deadline = time.time() + timeout
|
||||||
deadline = 0
|
while count:
|
||||||
else:
|
# fill buckets first
|
||||||
deadline = time.time() + timeout
|
update_sent()
|
||||||
while map and count > 0:
|
update_received()
|
||||||
# fill buckets first
|
subtimeout = deadline - time.time()
|
||||||
update_sent()
|
if subtimeout <= 0:
|
||||||
update_received()
|
break
|
||||||
subtimeout = deadline - time.time()
|
# then poll
|
||||||
if subtimeout <= 0:
|
poller(subtimeout, map)
|
||||||
break
|
if type(count) is int:
|
||||||
poller(subtimeout, map)
|
|
||||||
# then poll
|
|
||||||
count = count - 1
|
count = count - 1
|
||||||
|
|
||||||
class dispatcher:
|
class dispatcher:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user