fix event loop
This commit is contained in:
parent
0f23b58656
commit
ad4b65346c
1 changed files with 3 additions and 7 deletions
|
@ -149,7 +149,7 @@ class EventLoop(object):
|
||||||
else:
|
else:
|
||||||
raise Exception('can not find any available functions in select '
|
raise Exception('can not find any available functions in select '
|
||||||
'package')
|
'package')
|
||||||
self._fd_to_f = defaultdict(list)
|
self._fd_to_f = {}
|
||||||
|
|
||||||
def poll(self, timeout=None):
|
def poll(self, timeout=None):
|
||||||
events = self._impl.poll(timeout)
|
events = self._impl.poll(timeout)
|
||||||
|
@ -157,16 +157,12 @@ class EventLoop(object):
|
||||||
|
|
||||||
def add(self, f, mode):
|
def add(self, f, mode):
|
||||||
fd = f.fileno()
|
fd = f.fileno()
|
||||||
self._fd_to_f[fd].append(f)
|
self._fd_to_f[fd] = f
|
||||||
self._impl.add_fd(fd, mode)
|
self._impl.add_fd(fd, mode)
|
||||||
|
|
||||||
def remove(self, f):
|
def remove(self, f):
|
||||||
fd = f.fileno()
|
fd = f.fileno()
|
||||||
a = self._fd_to_f[fd]
|
|
||||||
if len(a) <= 1:
|
|
||||||
self._fd_to_f[fd] = None
|
self._fd_to_f[fd] = None
|
||||||
else:
|
|
||||||
a.remove(f)
|
|
||||||
self._impl.remove_fd(fd)
|
self._impl.remove_fd(fd)
|
||||||
|
|
||||||
def modify(self, f, mode):
|
def modify(self, f, mode):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue