Merge
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -13,6 +13,7 @@ Contributors
|
||||
* Patrick Carlisle
|
||||
* Brantley Harris
|
||||
* Gregory Holt
|
||||
* Joe Malicki
|
||||
* Chet Murthy
|
||||
* Eugene Oden
|
||||
* radix
|
||||
|
@@ -41,7 +41,7 @@ easy_install eventlet
|
||||
|
||||
<p>Alternately, you can download the source tarball:
|
||||
<ul>
|
||||
<li><a href="http://pypi.python.org/packages/source/e/eventlet/eventlet-0.9.5.tar.gz">eventlet-0.9.5.tar.gz</a></li>
|
||||
<li><a href="http://pypi.python.org/packages/source/e/eventlet/eventlet-0.9.6.tar.gz">eventlet-0.9.6.tar.gz</a></li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
version_info = (0, 9, 6, "dev1")
|
||||
version_info = (0, 9, 6)
|
||||
__version__ = ".".join(map(str, version_info))
|
||||
|
||||
try:
|
||||
|
@@ -32,12 +32,12 @@ class GreenConnection(greenio.GreenSocket):
|
||||
except WantReadError:
|
||||
trampoline(self.fd.fileno(),
|
||||
read=True,
|
||||
timeout=self.timeout,
|
||||
timeout=self.gettimeout(),
|
||||
timeout_exc=socket.timeout)
|
||||
except WantWriteError:
|
||||
trampoline(self.fd.fileno(),
|
||||
write=True,
|
||||
timeout=self.timeout,
|
||||
timeout=self.gettimeout(),
|
||||
timeout_exc=socket.timeout)
|
||||
|
||||
def dup(self):
|
||||
@@ -81,12 +81,12 @@ class GreenConnection(greenio.GreenSocket):
|
||||
except WantReadError:
|
||||
trampoline(self.fd.fileno(),
|
||||
read=True,
|
||||
timeout=self.timeout,
|
||||
timeout=self.gettimeout(),
|
||||
timeout_exc=socket.timeout)
|
||||
except WantWriteError:
|
||||
trampoline(self.fd.fileno(),
|
||||
write=True,
|
||||
timeout=self.timeout,
|
||||
timeout=self.gettimeout(),
|
||||
timeout_exc=socket.timeout)
|
||||
except SysCallError, e:
|
||||
if e[0] == -1 or e[0] > 0:
|
||||
@@ -111,12 +111,12 @@ class GreenConnection(greenio.GreenSocket):
|
||||
except WantReadError:
|
||||
trampoline(self.fd.fileno(),
|
||||
read=True,
|
||||
timeout=self.timeout,
|
||||
timeout=self.gettimeout(),
|
||||
timeout_exc=socket.timeout)
|
||||
except WantWriteError:
|
||||
trampoline(self.fd.fileno(),
|
||||
write=True,
|
||||
timeout=self.timeout,
|
||||
timeout=self.gettimeout(),
|
||||
timeout_exc=socket.timeout)
|
||||
|
||||
send = write
|
||||
@@ -148,12 +148,12 @@ class GreenConnection(greenio.GreenSocket):
|
||||
except WantReadError:
|
||||
trampoline(self.fd.fileno(),
|
||||
read=True,
|
||||
timeout=self.timeout,
|
||||
timeout=self.gettimeout(),
|
||||
timeout_exc=socket.timeout)
|
||||
except WantWriteError:
|
||||
trampoline(self.fd.fileno(),
|
||||
write=True,
|
||||
timeout=self.timeout,
|
||||
timeout=self.gettimeout(),
|
||||
timeout_exc=socket.timeout)
|
||||
|
||||
|
||||
@@ -183,4 +183,4 @@ class GreenConnection(greenio.GreenSocket):
|
||||
|
||||
Connection = ConnectionType = GreenConnection
|
||||
|
||||
del greenio
|
||||
del greenio
|
||||
|
@@ -1,8 +1,9 @@
|
||||
os_orig = __import__("os")
|
||||
import errno
|
||||
import socket
|
||||
socket = __import__("socket")
|
||||
|
||||
from eventlet import greenio
|
||||
from eventlet.greenio import get_errno
|
||||
from eventlet import greenthread
|
||||
from eventlet import hubs
|
||||
|
||||
@@ -27,10 +28,10 @@ def read(fd, n):
|
||||
try:
|
||||
return __original_read__(fd, n)
|
||||
except (OSError, IOError), e:
|
||||
if e[0] != errno.EAGAIN:
|
||||
if get_errno(e) != errno.EAGAIN:
|
||||
raise
|
||||
except socket.error, e:
|
||||
if e[0] == errno.EPIPE:
|
||||
if get_errno(e) == errno.EPIPE:
|
||||
return ''
|
||||
raise
|
||||
hubs.trampoline(fd, read=True)
|
||||
@@ -45,10 +46,10 @@ def write(fd, st):
|
||||
try:
|
||||
return __original_write__(fd, st)
|
||||
except (OSError, IOError), e:
|
||||
if e[0] != errno.EAGAIN:
|
||||
if get_errno(e) != errno.EAGAIN:
|
||||
raise
|
||||
except socket.error, e:
|
||||
if e[0] != errno.EPIPE:
|
||||
if get_errno(e) != errno.EPIPE:
|
||||
raise
|
||||
hubs.trampoline(fd, write=True)
|
||||
|
||||
@@ -74,4 +75,4 @@ def waitpid(pid, options):
|
||||
return rpid, status
|
||||
greenthread.sleep(0.01)
|
||||
|
||||
# TODO: open
|
||||
# TODO: open
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
"""This module is API-equivalent to the standard library :mod:`profile` module but it is greenthread-aware as well as thread-aware. Use this module
|
||||
to profile Eventlet-based applications in preference to either :mod:`profile` or :mod:`cProfile`.
|
||||
FIXME: No testcases for this module.
|
||||
"""
|
||||
|
||||
profile_orig = __import__('profile')
|
||||
@@ -34,12 +35,12 @@ for var in profile_orig.__all__:
|
||||
|
||||
import new
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
import thread
|
||||
import functools
|
||||
|
||||
from eventlet import greenthread
|
||||
from eventlet import patcher
|
||||
thread = patcher.original('thread') # non-monkeypatched module needed
|
||||
|
||||
#This class provides the start() and stop() functions
|
||||
class Profile(profile_orig.Profile):
|
||||
|
@@ -1,27 +1,34 @@
|
||||
__socket = __import__('socket')
|
||||
for var in __socket.__all__:
|
||||
exec "%s = __socket.%s" % (var, var)
|
||||
_fileobject = __socket._fileobject
|
||||
|
||||
from eventlet.hubs import get_hub
|
||||
from eventlet.greenio import GreenSocket as socket
|
||||
from eventlet.greenio import SSL as _SSL # for exceptions
|
||||
from eventlet.greenio import _GLOBAL_DEFAULT_TIMEOUT
|
||||
import os
|
||||
from eventlet.greenio import _fileobject
|
||||
|
||||
os = __import__('os')
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
__patched__ = ['fromfd', 'socketpair', 'gethostbyname', 'create_connection',
|
||||
'ssl', 'socket']
|
||||
|
||||
__original_fromfd__ = __socket.fromfd
|
||||
def fromfd(*args):
|
||||
return socket(__original_fromfd__(*args))
|
||||
try:
|
||||
__original_fromfd__ = __socket.fromfd
|
||||
def fromfd(*args):
|
||||
return socket(__original_fromfd__(*args))
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
__original_socketpair__ = __socket.socketpair
|
||||
def socketpair(*args):
|
||||
one, two = __original_socketpair__(*args)
|
||||
return socket(one), socket(two)
|
||||
try:
|
||||
__original_socketpair__ = __socket.socketpair
|
||||
def socketpair(*args):
|
||||
one, two = __original_socketpair__(*args)
|
||||
return socket(one), socket(two)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
__original_gethostbyname__ = __socket.gethostbyname
|
||||
def gethostbyname(name):
|
||||
|
@@ -4,11 +4,10 @@ for attr in dir(__ssl):
|
||||
exec "%s = __ssl.%s" % (attr, attr)
|
||||
|
||||
import errno
|
||||
import time
|
||||
time = __import__('time')
|
||||
|
||||
from eventlet.hubs import trampoline
|
||||
from thread import get_ident
|
||||
from eventlet.greenio import set_nonblocking, GreenSocket, SOCKET_CLOSED, CONNECT_ERR, CONNECT_SUCCESS
|
||||
from eventlet.greenio import set_nonblocking, GreenSocket, SOCKET_CLOSED, CONNECT_ERR, CONNECT_SUCCESS, get_errno
|
||||
orig_socket = __import__('socket')
|
||||
socket = orig_socket.socket
|
||||
timeout_exc = orig_socket.timeout
|
||||
@@ -36,7 +35,7 @@ class GreenSSLSocket(__ssl.SSLSocket):
|
||||
sock = GreenSocket(sock)
|
||||
|
||||
self.act_non_blocking = sock.act_non_blocking
|
||||
self.timeout = sock.timeout
|
||||
self._timeout = sock.gettimeout()
|
||||
super(GreenSSLSocket, self).__init__(sock.fd, *args, **kw)
|
||||
del sock
|
||||
|
||||
@@ -49,18 +48,18 @@ class GreenSSLSocket(__ssl.SSLSocket):
|
||||
self.recvfrom_into = lambda buffer, nbytes=None, flags=0: GreenSSLSocket.recvfrom_into(self, buffer, nbytes, flags)
|
||||
|
||||
def settimeout(self, timeout):
|
||||
self.timeout = timeout
|
||||
self._timeout = timeout
|
||||
|
||||
def gettimeout(self):
|
||||
return self.timeout
|
||||
return self._timeout
|
||||
|
||||
def setblocking(self, flag):
|
||||
if flag:
|
||||
self.act_non_blocking = False
|
||||
self.timeout = None
|
||||
self._timeout = None
|
||||
else:
|
||||
self.act_non_blocking = True
|
||||
self.timeout = 0.0
|
||||
self._timeout = 0.0
|
||||
|
||||
def _call_trampolining(self, func, *a, **kw):
|
||||
if self.act_non_blocking:
|
||||
@@ -70,12 +69,12 @@ class GreenSSLSocket(__ssl.SSLSocket):
|
||||
try:
|
||||
return func(*a, **kw)
|
||||
except SSLError, exc:
|
||||
if exc[0] == SSL_ERROR_WANT_READ:
|
||||
if get_errno(exc) == SSL_ERROR_WANT_READ:
|
||||
trampoline(self.fileno(),
|
||||
read=True,
|
||||
timeout=self.gettimeout(),
|
||||
timeout_exc=timeout_exc('timed out'))
|
||||
elif exc[0] == SSL_ERROR_WANT_WRITE:
|
||||
elif get_errno(exc) == SSL_ERROR_WANT_WRITE:
|
||||
trampoline(self.fileno(),
|
||||
write=True,
|
||||
timeout=self.gettimeout(),
|
||||
@@ -107,9 +106,9 @@ class GreenSSLSocket(__ssl.SSLSocket):
|
||||
try:
|
||||
v = self._sslobj.write(data)
|
||||
except SSLError, x:
|
||||
if x.args[0] == SSL_ERROR_WANT_READ:
|
||||
if get_errno(x) == SSL_ERROR_WANT_READ:
|
||||
return 0
|
||||
elif x.args[0] == SSL_ERROR_WANT_WRITE:
|
||||
elif get_errno(x) == SSL_ERROR_WANT_WRITE:
|
||||
return 0
|
||||
else:
|
||||
raise
|
||||
@@ -122,8 +121,8 @@ class GreenSSLSocket(__ssl.SSLSocket):
|
||||
except orig_socket.error, e:
|
||||
if self.act_non_blocking:
|
||||
raise
|
||||
if e[0] == errno.EWOULDBLOCK or \
|
||||
e[0] == errno.ENOTCONN:
|
||||
if get_errno(e) == errno.EWOULDBLOCK or \
|
||||
get_errno(e) == errno.ENOTCONN:
|
||||
return 0
|
||||
raise
|
||||
|
||||
@@ -156,10 +155,10 @@ class GreenSSLSocket(__ssl.SSLSocket):
|
||||
except orig_socket.error, e:
|
||||
if self.act_non_blocking:
|
||||
raise
|
||||
if e[0] == errno.EWOULDBLOCK:
|
||||
if ge_errno(e) == errno.EWOULDBLOCK:
|
||||
trampoline(self.fileno(), write=True,
|
||||
timeout=self.gettimeout(), timeout_exc=timeout_exc('timed out'))
|
||||
if e[0] in SOCKET_CLOSED:
|
||||
if get_errno(e) in SOCKET_CLOSED:
|
||||
return ''
|
||||
raise
|
||||
|
||||
@@ -179,10 +178,10 @@ class GreenSSLSocket(__ssl.SSLSocket):
|
||||
except orig_socket.error, e:
|
||||
if self.act_non_blocking:
|
||||
raise
|
||||
if e[0] == errno.EWOULDBLOCK:
|
||||
if get_errno(e) == errno.EWOULDBLOCK:
|
||||
trampoline(self.fileno(), read=True,
|
||||
timeout=self.gettimeout(), timeout_exc=timeout_exc('timed out'))
|
||||
if e[0] in SOCKET_CLOSED:
|
||||
if get_errno(e) in SOCKET_CLOSED:
|
||||
return ''
|
||||
raise
|
||||
|
||||
@@ -222,9 +221,9 @@ class GreenSSLSocket(__ssl.SSLSocket):
|
||||
try:
|
||||
return real_connect(self, addr)
|
||||
except orig_socket.error, exc:
|
||||
if exc[0] in CONNECT_ERR:
|
||||
if get_errno(exc) in CONNECT_ERR:
|
||||
trampoline(self.fileno(), write=True)
|
||||
elif exc[0] in CONNECT_SUCCESS:
|
||||
elif get_errno(exc) in CONNECT_SUCCESS:
|
||||
return
|
||||
else:
|
||||
raise
|
||||
@@ -234,10 +233,10 @@ class GreenSSLSocket(__ssl.SSLSocket):
|
||||
try:
|
||||
real_connect(self, addr)
|
||||
except orig_socket.error, exc:
|
||||
if exc[0] in CONNECT_ERR:
|
||||
if get_errno(exc) in CONNECT_ERR:
|
||||
trampoline(self.fileno(), write=True,
|
||||
timeout=end-time.time(), timeout_exc=timeout_exc('timed out'))
|
||||
elif exc[0] in CONNECT_SUCCESS:
|
||||
elif get_errno(exc) in CONNECT_SUCCESS:
|
||||
return
|
||||
else:
|
||||
raise
|
||||
@@ -273,7 +272,7 @@ class GreenSSLSocket(__ssl.SSLSocket):
|
||||
set_nonblocking(newsock)
|
||||
break
|
||||
except orig_socket.error, e:
|
||||
if e[0] != errno.EWOULDBLOCK:
|
||||
if get_errno(e) != errno.EWOULDBLOCK:
|
||||
raise
|
||||
trampoline(self.fileno(), read=True, timeout=self.gettimeout(),
|
||||
timeout_exc=timeout_exc('timed out'))
|
||||
|
@@ -14,6 +14,27 @@ __all__ = ['GreenSocket', 'GreenPipe', 'shutdown_safe']
|
||||
CONNECT_ERR = set((errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK))
|
||||
CONNECT_SUCCESS = set((0, errno.EISCONN))
|
||||
|
||||
# Emulate _fileobject class in 3.x implementation
|
||||
# Eventually this internal socket structure could be replaced with makefile calls.
|
||||
try:
|
||||
_fileobject = socket._fileobject
|
||||
except AttributeError:
|
||||
def _fileobject(sock, *args, **kwargs):
|
||||
return _original_socket.makefile(sock, *args, **kwargs)
|
||||
|
||||
def get_errno(exc):
|
||||
""" Get the error code out of socket.error objects.
|
||||
socket.error in <2.5 does not have errno attribute
|
||||
socket.error in 3.x does not allow indexing access
|
||||
"""
|
||||
try:
|
||||
return exc.args[0]
|
||||
except (TypeError,IndexError):
|
||||
try:
|
||||
return exc.errno
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
def socket_connect(descriptor, address):
|
||||
"""
|
||||
Attempts to connect to the address, returns the descriptor if it succeeds,
|
||||
@@ -36,7 +57,7 @@ def socket_accept(descriptor):
|
||||
try:
|
||||
return descriptor.accept()
|
||||
except socket.error, e:
|
||||
if e[0] == errno.EWOULDBLOCK:
|
||||
if get_errno(e) == errno.EWOULDBLOCK:
|
||||
return None
|
||||
raise
|
||||
|
||||
@@ -96,7 +117,6 @@ class GreenSocket(object):
|
||||
Green version of socket.socket class, that is intended to be 100%
|
||||
API-compatible.
|
||||
"""
|
||||
timeout = None
|
||||
def __init__(self, family_or_realsock=socket.AF_INET, *args, **kwargs):
|
||||
if isinstance(family_or_realsock, (int, long)):
|
||||
fd = _original_socket(family_or_realsock, *args, **kwargs)
|
||||
@@ -107,10 +127,10 @@ class GreenSocket(object):
|
||||
|
||||
# import timeout from other socket, if it was there
|
||||
try:
|
||||
self.timeout = fd.gettimeout() or socket.getdefaulttimeout()
|
||||
self._timeout = fd.gettimeout() or socket.getdefaulttimeout()
|
||||
except AttributeError:
|
||||
self.timeout = socket.getdefaulttimeout()
|
||||
|
||||
self._timeout = socket.getdefaulttimeout()
|
||||
|
||||
set_nonblocking(fd)
|
||||
self.fd = fd
|
||||
self.closed = False
|
||||
@@ -134,6 +154,11 @@ class GreenSocket(object):
|
||||
def proto(self):
|
||||
return self.fd.proto
|
||||
|
||||
#forward unknown requests to fd
|
||||
#i.e _io_refs and _decref_socketios in 3.x
|
||||
def __getattr__(self, value):
|
||||
return getattr(self.fd, value)
|
||||
|
||||
def accept(self):
|
||||
if self.act_non_blocking:
|
||||
return self.fd.accept()
|
||||
@@ -184,7 +209,7 @@ class GreenSocket(object):
|
||||
try:
|
||||
trampoline(fd, write=True)
|
||||
except socket.error, ex:
|
||||
return ex[0]
|
||||
return get_errno(ex)
|
||||
else:
|
||||
end = time.time() + self.gettimeout()
|
||||
while True:
|
||||
@@ -196,13 +221,13 @@ class GreenSocket(object):
|
||||
trampoline(fd, write=True, timeout=end-time.time(),
|
||||
timeout_exc=socket.timeout(errno.EAGAIN))
|
||||
except socket.error, ex:
|
||||
return ex[0]
|
||||
return get_errno(ex)
|
||||
|
||||
def dup(self, *args, **kw):
|
||||
sock = self.fd.dup(*args, **kw)
|
||||
set_nonblocking(sock)
|
||||
newsock = type(self)(sock)
|
||||
newsock.settimeout(self.timeout)
|
||||
newsock.settimeout(self.gettimeout())
|
||||
return newsock
|
||||
|
||||
def fileno(self, *args, **kw):
|
||||
@@ -225,8 +250,8 @@ class GreenSocket(object):
|
||||
fn = self.listen = self.fd.listen
|
||||
return fn(*args, **kw)
|
||||
|
||||
def makefile(self, mode='r', bufsize=-1):
|
||||
return socket._fileobject(self.dup(), mode, bufsize)
|
||||
def makefile(self, *args, **kw):
|
||||
return _fileobject(self.dup(), *args, **kw)
|
||||
|
||||
def makeGreenFile(self, mode='r', bufsize=-1):
|
||||
warnings.warn("makeGreenFile has been deprecated, please use "
|
||||
@@ -241,15 +266,15 @@ class GreenSocket(object):
|
||||
try:
|
||||
return fd.recv(buflen, flags)
|
||||
except socket.error, e:
|
||||
if e[0] in SOCKET_BLOCKING:
|
||||
if get_errno(e) in SOCKET_BLOCKING:
|
||||
pass
|
||||
elif e[0] in SOCKET_CLOSED:
|
||||
elif get_errno(e) in SOCKET_CLOSED:
|
||||
return ''
|
||||
else:
|
||||
raise
|
||||
trampoline(fd,
|
||||
read=True,
|
||||
timeout=self.timeout,
|
||||
trampoline(fd,
|
||||
read=True,
|
||||
timeout=self.gettimeout(),
|
||||
timeout_exc=socket.timeout("timed out"))
|
||||
|
||||
def recvfrom(self, *args):
|
||||
@@ -283,7 +308,7 @@ class GreenSocket(object):
|
||||
try:
|
||||
total_sent += fd.send(data[total_sent:], flags)
|
||||
except socket.error, e:
|
||||
if e[0] not in SOCKET_BLOCKING:
|
||||
if get_errno(e) not in SOCKET_BLOCKING:
|
||||
raise
|
||||
|
||||
if total_sent == len_data:
|
||||
@@ -307,10 +332,10 @@ class GreenSocket(object):
|
||||
def setblocking(self, flag):
|
||||
if flag:
|
||||
self.act_non_blocking = False
|
||||
self.timeout = None
|
||||
self._timeout = None
|
||||
else:
|
||||
self.act_non_blocking = True
|
||||
self.timeout = 0.0
|
||||
self._timeout = 0.0
|
||||
|
||||
def setsockopt(self, *args, **kw):
|
||||
fn = self.setsockopt = self.fd.setsockopt
|
||||
@@ -334,10 +359,10 @@ class GreenSocket(object):
|
||||
if howlong == 0.0:
|
||||
self.setblocking(howlong)
|
||||
else:
|
||||
self.timeout = howlong
|
||||
self._timeout = howlong
|
||||
|
||||
def gettimeout(self):
|
||||
return self.timeout
|
||||
return self._timeout
|
||||
|
||||
|
||||
class GreenPipe(object):
|
||||
@@ -367,10 +392,10 @@ class GreenPipe(object):
|
||||
try:
|
||||
return fd.read(buflen)
|
||||
except IOError, e:
|
||||
if e[0] != errno.EAGAIN:
|
||||
if get_errno(e) != errno.EAGAIN:
|
||||
return ''
|
||||
except socket.error, e:
|
||||
if e[0] == errno.EPIPE:
|
||||
if get_errno(e) == errno.EPIPE:
|
||||
return ''
|
||||
raise
|
||||
trampoline(fd, read=True)
|
||||
@@ -399,13 +424,13 @@ class GreenPipe(object):
|
||||
fd.flush()
|
||||
return len(data)
|
||||
except IOError, e:
|
||||
if e[0] != errno.EAGAIN:
|
||||
if get_errno(e) != errno.EAGAIN:
|
||||
raise
|
||||
except ValueError, e:
|
||||
# what's this for?
|
||||
pass
|
||||
except socket.error, e:
|
||||
if e[0] != errno.EPIPE:
|
||||
if get_errno(e) != errno.EPIPE:
|
||||
raise
|
||||
trampoline(fd, write=True)
|
||||
|
||||
@@ -506,6 +531,6 @@ def shutdown_safe(sock):
|
||||
except socket.error, e:
|
||||
# we don't care if the socket is already closed;
|
||||
# this will often be the case in an http server context
|
||||
if e[0] != errno.ENOTCONN:
|
||||
if get_errno(e) != errno.ENOTCONN:
|
||||
raise
|
||||
|
||||
|
@@ -7,6 +7,13 @@ from eventlet.hubs import timer
|
||||
from eventlet import patcher
|
||||
time = patcher.original('time')
|
||||
|
||||
# In py3k exception information is not visible outside of except statements
|
||||
# so sys.exc_clear become obsolete and removed.
|
||||
try:
|
||||
sys_exc_clear = sys.exc_clear
|
||||
except AttributeError:
|
||||
sys_exc_clear = lambda: None
|
||||
|
||||
READ="read"
|
||||
WRITE="write"
|
||||
|
||||
@@ -111,7 +118,7 @@ class BaseHub(object):
|
||||
cur.parent = self.greenlet
|
||||
except ValueError:
|
||||
pass # gets raised if there is a greenlet parent cycle
|
||||
sys.exc_clear()
|
||||
sys_exc_clear()
|
||||
return self.greenlet.switch()
|
||||
|
||||
def squelch_exception(self, fileno, exc_info):
|
||||
|
@@ -234,7 +234,7 @@ def setup():
|
||||
csock = util.__original_socket__(socket.AF_INET, socket.SOCK_STREAM)
|
||||
csock.connect(('localhost', sock.getsockname()[1]))
|
||||
nsock, addr = sock.accept()
|
||||
_rfile = greenio.Green_fileobject(greenio.GreenSocket(csock))
|
||||
_rfile = greenio.GreenSocket(csock).makefile()
|
||||
_wfile = nsock.makefile()
|
||||
|
||||
_reqq = Queue(maxsize=-1)
|
||||
|
@@ -10,6 +10,7 @@ from eventlet.green import socket
|
||||
from eventlet.green import BaseHTTPServer
|
||||
from eventlet import greenpool
|
||||
from eventlet import greenio
|
||||
from eventlet.greenio import get_errno
|
||||
|
||||
DEFAULT_MAX_SIMULTANEOUS_REQUESTS = 1024
|
||||
DEFAULT_MAX_HTTP_VERSION = 'HTTP/1.1'
|
||||
@@ -41,15 +42,6 @@ BROKEN_SOCK = set((errno.EPIPE, errno.ECONNRESET))
|
||||
# special flag return value for apps
|
||||
ALREADY_HANDLED = object()
|
||||
|
||||
def get_errno(err):
|
||||
""" Simple method to get the error code out of socket.error objects. It
|
||||
compensates for some cases where the code is not in the expected
|
||||
location."""
|
||||
try:
|
||||
return err[0]
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
class Input(object):
|
||||
def __init__(self,
|
||||
rfile,
|
||||
|
@@ -41,7 +41,7 @@ class TestApi(TestCase):
|
||||
def accept_once(listenfd):
|
||||
try:
|
||||
conn, addr = listenfd.accept()
|
||||
fd = conn.makefile()
|
||||
fd = conn.makefile(mode='w')
|
||||
conn.close()
|
||||
fd.write('hello\n')
|
||||
fd.close()
|
||||
|
@@ -43,7 +43,7 @@ class TestGreenIo(LimitedTestCase):
|
||||
self.assertEqual(e.args[0], 'timed out')
|
||||
except socket.error, e:
|
||||
# unreachable is also a valid outcome
|
||||
if not e[0] in (errno.EHOSTUNREACH, errno.ENETUNREACH):
|
||||
if not get_errno(e) in (errno.EHOSTUNREACH, errno.ENETUNREACH):
|
||||
raise
|
||||
|
||||
def test_accept_timeout(self):
|
||||
|
Reference in New Issue
Block a user