diff options
| author | Michael Kerrin <michael.kerrin@hp.com> | 2014-06-25 09:13:02 +0100 |
|---|---|---|
| committer | Sergey Shepelev <temotor@gmail.com> | 2014-08-12 12:10:42 +0400 |
| commit | 8f98f8b63443394dbcf8c506a2a2686b3c933ce9 (patch) | |
| tree | 62568c975fece21467da16c66acc5f4ff5a94070 | |
| parent | da87716714689894f23d0db7b003f26d97031e83 (diff) | |
| download | eventlet-94-second-read.tar.gz | |
hubs: defang after remove; related to second simultaneous read issue94-second-read
https://github.com/eventlet/eventlet/issues/94
We have to defang the listener after removing it from the hub
Otherwise we never actaully remove it from the hub and get a return of the
second simultanous read.
This should fix this issue.
Turn off __builtin__ monkey patching by default
The reason is that eventlet.greenio.GreenPipe tries to
adapt an original file f, and performs the following check
isinstance(f, file) f is an original file object with file
is now our file method. This fails causing TypeError
nova-api exercises this
Fix up zmq to use the extended add signature
Having heard no problems relating eventlet and zmq,
I'm not going to dive in and drop random pataches against
it. If the 'Second simultaneous *er' crops up against
zmw then we at least now have the machinery to
address it.
| -rw-r--r-- | eventlet/green/select.py | 4 | ||||
| -rw-r--r-- | eventlet/green/zmq.py | 6 | ||||
| -rw-r--r-- | eventlet/greenio.py | 10 | ||||
| -rw-r--r-- | eventlet/hubs/hub.py | 5 | ||||
| -rw-r--r-- | eventlet/patcher.py | 2 |
5 files changed, 17 insertions, 10 deletions
diff --git a/eventlet/green/select.py b/eventlet/green/select.py index 2d30bca..53e7444 100644 --- a/eventlet/green/select.py +++ b/eventlet/green/select.py @@ -76,9 +76,9 @@ def select(read_list, write_list, error_list, timeout=None): try: for k, v in six.iteritems(ds): if v.get('read'): - listeners.append(hub.add(hub.READ, k, on_read)) + listeners.append(hub.add(hub.READ, k, on_read, on_error, lambda x: None)) if v.get('write'): - listeners.append(hub.add(hub.WRITE, k, on_write)) + listeners.append(hub.add(hub.WRITE, k, on_write, on_error, lambda x: None)) try: return hub.switch() finally: diff --git a/eventlet/green/zmq.py b/eventlet/green/zmq.py index ee6ff06..07d5c81 100644 --- a/eventlet/green/zmq.py +++ b/eventlet/green/zmq.py @@ -227,7 +227,11 @@ class Socket(_Socket): _Socket_getsockopt(self, EVENTS) hub = hubs.get_hub() - self.__dict__['_eventlet_listener'] = hub.add(hub.READ, self.getsockopt(FD), event) + self.__dict__['_eventlet_listener'] = hub.add(hub.READ, + self.getsockopt(FD), + event, + lambda _: None, + lambda: None) @_wraps(_Socket.close) def close(self, linger=None): diff --git a/eventlet/greenio.py b/eventlet/greenio.py index f099826..9c169ed 100644 --- a/eventlet/greenio.py +++ b/eventlet/greenio.py @@ -180,8 +180,8 @@ class GreenSocket(object): # socket here would be useful. raise IOClosed() try: - return trampoline(fd, read=True, timeout=self.gettimeout(), - timeout_exc=socket.timeout("timed out"), + return trampoline(fd, read=read, write=write, timeout=timeout, + timeout_exc=timeout_exc, mark_as_closed=self._mark_as_closed) except IOClosed: # This socket's been obsoleted. De-fang it. @@ -423,9 +423,9 @@ class _SocketDuckForFd(object): # Don't trampoline if we're already closed. raise IOClosed() try: - return trampoline(fd, read=True, timeout=self.gettimeout(), - timeout_exc=socket.timeout("timed out"), - mark_as_closed=self.mark_as_closed) + return trampoline(fd, read=read, write=write, timeout=timeout, + timeout_exc=timeout_exc, + mark_as_closed=self._mark_as_closed) except IOClosed: # Our fileno has been obsoleted. Defang ourselves to # prevent spurious closes. diff --git a/eventlet/hubs/hub.py b/eventlet/hubs/hub.py index c0ecc13..d2841c3 100644 --- a/eventlet/hubs/hub.py +++ b/eventlet/hubs/hub.py @@ -193,9 +193,9 @@ class BaseHub(object): if fileno in bucket: listener = bucket[fileno] found = True - listener.defang() - self.closed.append(bucket[fileno]) + self.closed.append(listener) self.remove(listener) + listener.defang() return found @@ -210,6 +210,7 @@ class BaseHub(object): if listener.spent: # trampoline may trigger this in its finally section. return + fileno = listener.fileno evtype = listener.evtype self.listeners[evtype].pop(fileno, None) diff --git a/eventlet/patcher.py b/eventlet/patcher.py index 1ba921e..bef702e 100644 --- a/eventlet/patcher.py +++ b/eventlet/patcher.py @@ -227,6 +227,8 @@ def monkey_patch(**on): if modname == 'MySQLdb': # MySQLdb is only on when explicitly patched for the moment on.setdefault(modname, False) + if modname == '__builtin__': + on.setdefault(modname, False) on.setdefault(modname, default_on) modules_to_patch = [] |
