Removed previously-deprecated features tcp_server, GreenSSL, erpc, and trap_errors.
This commit is contained in:
1
NEWS
1
NEWS
@@ -1,6 +1,7 @@
|
|||||||
0.9.3
|
0.9.3
|
||||||
=====
|
=====
|
||||||
|
|
||||||
|
* Removed previously-deprecated features tcp_server, GreenSSL, erpc, and trap_errors.
|
||||||
* Removed saranwrap as an option for making db connections nonblocking in db_pool.
|
* Removed saranwrap as an option for making db connections nonblocking in db_pool.
|
||||||
|
|
||||||
0.9.2
|
0.9.2
|
||||||
|
@@ -68,40 +68,6 @@ def connect_tcp(address, localaddr=None):
|
|||||||
desc.connect(address)
|
desc.connect(address)
|
||||||
return desc
|
return desc
|
||||||
|
|
||||||
def tcp_server(listensocket, server, *args, **kw):
|
|
||||||
"""
|
|
||||||
**Deprecated** Please write your own accept loop instead, like this::
|
|
||||||
|
|
||||||
while True:
|
|
||||||
api.spawn(server, listensocket.accept(), <other_args>)
|
|
||||||
|
|
||||||
A more complex accept loop can be found in ``examples/accept_loop.py``.
|
|
||||||
|
|
||||||
*Original documentation:*
|
|
||||||
Given a socket, accept connections forever, spawning greenlets and
|
|
||||||
executing *server* for each new incoming connection. When *server* returns
|
|
||||||
False, the :func:`tcp_server()` greenlet will end.
|
|
||||||
|
|
||||||
:param listensocket: The socket from which to accept connections.
|
|
||||||
:param server: The callable to call when a new connection is made.
|
|
||||||
:param \*args: The positional arguments to pass to *server*.
|
|
||||||
:param \*\*kw: The keyword arguments to pass to *server*.
|
|
||||||
"""
|
|
||||||
warnings.warn("tcp_server is deprecated, please write your own "\
|
|
||||||
"accept loop instead (see examples/accept_loop.py)",
|
|
||||||
DeprecationWarning, stacklevel=2)
|
|
||||||
working = [True]
|
|
||||||
try:
|
|
||||||
while working[0] is not False:
|
|
||||||
def tcp_server_wrapper(sock):
|
|
||||||
working[0] = server(sock, *args, **kw)
|
|
||||||
spawn(tcp_server_wrapper, listensocket.accept())
|
|
||||||
except socket.timeout, e:
|
|
||||||
raise
|
|
||||||
except socket.error, e:
|
|
||||||
# EBADF means the socket was closed
|
|
||||||
if e[0] is not errno.EBADF:
|
|
||||||
raise
|
|
||||||
|
|
||||||
def trampoline(fd, read=None, write=None, timeout=None, timeout_exc=TimeoutError):
|
def trampoline(fd, read=None, write=None, timeout=None, timeout_exc=TimeoutError):
|
||||||
"""Suspend the current coroutine until the given socket object or file
|
"""Suspend the current coroutine until the given socket object or file
|
||||||
|
@@ -513,21 +513,9 @@ class GreenPipe(Green_fileobject):
|
|||||||
self.fd.fd.flush()
|
self.fd.fd.flush()
|
||||||
|
|
||||||
|
|
||||||
# backwards compatibility with old GreenSSL stuff
|
# import SSL module here so we can refer to greenio.SSL.exceptionclass
|
||||||
try:
|
try:
|
||||||
from OpenSSL import SSL
|
from OpenSSL import SSL
|
||||||
def GreenSSL(fd):
|
|
||||||
assert isinstance(fd, (SSL.ConnectionType)), \
|
|
||||||
"GreenSSL must be constructed with an "\
|
|
||||||
"OpenSSL Connection object"
|
|
||||||
|
|
||||||
warnings.warn("GreenSSL is deprecated, please use "\
|
|
||||||
"eventlet.green.OpenSSL.Connection instead (if on "\
|
|
||||||
"Python 2.5) or eventlet.green.ssl.wrap_socket() "\
|
|
||||||
"(if on Python 2.6 or later)",
|
|
||||||
DeprecationWarning, stacklevel=2)
|
|
||||||
import eventlet.green.OpenSSL.SSL
|
|
||||||
return eventlet.green.OpenSSL.SSL.Connection(None, fd)
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# pyOpenSSL not installed, define exceptions anyway for convenience
|
# pyOpenSSL not installed, define exceptions anyway for convenience
|
||||||
class SSL(object):
|
class SSL(object):
|
||||||
|
@@ -613,16 +613,6 @@ def spawn_link_exception(function, *args, **kwargs):
|
|||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
||||||
def trap_errors(errors, func, *args, **kwargs):
|
|
||||||
"""DEPRECATED; use wrap_errors"""
|
|
||||||
import warnings
|
|
||||||
warnings.warn("proc.trap_errors function is deprecated in favor of proc.wrap_errors class",
|
|
||||||
DeprecationWarning, stacklevel=2)
|
|
||||||
try:
|
|
||||||
return func(*args, **kwargs)
|
|
||||||
except errors, ex:
|
|
||||||
return ex
|
|
||||||
|
|
||||||
|
|
||||||
class wrap_errors(object):
|
class wrap_errors(object):
|
||||||
"""Helper to make function return an exception, rather than raise it.
|
"""Helper to make function return an exception, rather than raise it.
|
||||||
|
@@ -99,12 +99,6 @@ def execute(meth,*args, **kwargs):
|
|||||||
rv = erecv(e)
|
rv = erecv(e)
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
def erpc(meth, *args, **kwargs):
|
|
||||||
import warnings
|
|
||||||
warnings.warn("erpc is deprecated. Call execute instead.",
|
|
||||||
DeprecationWarning, stacklevel=2)
|
|
||||||
execute(meth, *args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def proxy_call(autowrap, f, *args, **kwargs):
|
def proxy_call(autowrap, f, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@@ -91,34 +91,6 @@ class TestApi(TestCase):
|
|||||||
|
|
||||||
check_hub()
|
check_hub()
|
||||||
|
|
||||||
def test_tcp_server(self):
|
|
||||||
import warnings
|
|
||||||
# disabling tcp_server warnings because we're testing tcp_server here
|
|
||||||
warnings.filterwarnings(action = 'ignore',
|
|
||||||
message='.*tcp_server.*',
|
|
||||||
category=DeprecationWarning)
|
|
||||||
connected = []
|
|
||||||
server = api.tcp_listener(('0.0.0.0', 0))
|
|
||||||
bound_port = server.getsockname()[1]
|
|
||||||
|
|
||||||
done = [False]
|
|
||||||
def accept_twice((conn, addr)):
|
|
||||||
connected.append(True)
|
|
||||||
conn.close()
|
|
||||||
if len(connected) == 2:
|
|
||||||
server.close()
|
|
||||||
done[0] = True
|
|
||||||
|
|
||||||
api.call_after(0, api.connect_tcp, ('127.0.0.1', bound_port))
|
|
||||||
api.call_after(0, api.connect_tcp, ('127.0.0.1', bound_port))
|
|
||||||
server_coro = api.spawn(api.tcp_server, server, accept_twice)
|
|
||||||
while not done[0]:
|
|
||||||
api.sleep(0)
|
|
||||||
api.kill(server_coro)
|
|
||||||
|
|
||||||
assert len(connected) == 2
|
|
||||||
check_hub()
|
|
||||||
|
|
||||||
def test_001_trampoline_timeout(self):
|
def test_001_trampoline_timeout(self):
|
||||||
from eventlet import coros
|
from eventlet import coros
|
||||||
server_sock = api.tcp_listener(('127.0.0.1', 0))
|
server_sock = api.tcp_listener(('127.0.0.1', 0))
|
||||||
|
Reference in New Issue
Block a user