add traffic control for each TCP connection
This commit is contained in:
@@ -208,12 +208,13 @@ class EventLoop(object):
|
||||
traceback.print_exc()
|
||||
continue
|
||||
|
||||
handle = False
|
||||
for sock, fd, event in events:
|
||||
handler = self._fdmap.get(fd, None)
|
||||
if handler is not None:
|
||||
handler = handler[1]
|
||||
try:
|
||||
handler.handle_event(sock, fd, event)
|
||||
handle = handle or handler.handle_event(sock, fd, event)
|
||||
except (OSError, IOError) as e:
|
||||
shell.print_exception(e)
|
||||
now = time.time()
|
||||
@@ -221,6 +222,8 @@ class EventLoop(object):
|
||||
for callback in self._periodic_callbacks:
|
||||
callback()
|
||||
self._last_time = now
|
||||
if events and (handle is False):
|
||||
time.sleep(0.01)
|
||||
|
||||
def __del__(self):
|
||||
self._impl.close()
|
||||
|
||||
Reference in New Issue
Block a user