5 __original_socket__ = socket.socket
10 "eventlet.util.tcp_socket is deprecated. "
11 "Please use the standard socket technique for this instead: "
12 "sock = socket.socket()",
13 DeprecationWarning, stacklevel=2)
14 s = __original_socket__(socket.AF_INET, socket.SOCK_STREAM)
18 # if ssl is available, use eventlet.green.ssl for our ssl implementation
19 from eventlet.green import ssl
22 def wrap_ssl(sock, certificate=None, private_key=None, server_side=False):
24 "eventlet.util.wrap_ssl is deprecated. "
25 "Please use the eventlet.green.ssl.wrap_socket()",
26 DeprecationWarning, stacklevel=2)
27 return ssl.wrap_socket(
31 server_side=server_side,
35 def wrap_socket_with_coroutine_socket(use_thread_pool=None):
37 "eventlet.util.wrap_socket_with_coroutine_socket() is now "
38 "eventlet.patcher.monkey_patch(all=False, socket=True)",
39 DeprecationWarning, stacklevel=2)
40 from eventlet import patcher
41 patcher.monkey_patch(all=False, socket=True)
44 def wrap_pipes_with_coroutine_pipes():
46 "eventlet.util.wrap_pipes_with_coroutine_pipes() is now "
47 "eventlet.patcher.monkey_patch(all=False, os=True)",
48 DeprecationWarning, stacklevel=2)
49 from eventlet import patcher
50 patcher.monkey_patch(all=False, os=True)
53 def wrap_select_with_coroutine_select():
55 "eventlet.util.wrap_select_with_coroutine_select() is now "
56 "eventlet.patcher.monkey_patch(all=False, select=True)",
57 DeprecationWarning, stacklevel=2)
58 from eventlet import patcher
59 patcher.monkey_patch(all=False, select=True)
62 def wrap_threading_local_with_coro_local():
64 monkey patch ``threading.local`` with something that is greenlet aware.
65 Since greenlets cannot cross threads, so this should be semantically
66 identical to ``threadlocal.local``
69 "eventlet.util.wrap_threading_local_with_coro_local() is now "
70 "eventlet.patcher.monkey_patch(all=False, thread=True) -- though"
71 "note that more than just _local is patched now.",
72 DeprecationWarning, stacklevel=2)
74 from eventlet import patcher
75 patcher.monkey_patch(all=False, thread=True)
78 def socket_bind_and_listen(descriptor, addr=('', 0), backlog=50):
80 "eventlet.util.socket_bind_and_listen is deprecated."
81 "Please use the standard socket methodology for this instead:"
82 "sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR, 1)"
84 "sock.listen(backlog)",
85 DeprecationWarning, stacklevel=2)
86 set_reuse_addr(descriptor)
88 descriptor.listen(backlog)
92 def set_reuse_addr(descriptor):
94 "eventlet.util.set_reuse_addr is deprecated."
95 "Please use the standard socket methodology for this instead:"
96 "sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR, 1)",
97 DeprecationWarning, stacklevel=2)
99 descriptor.setsockopt(
102 descriptor.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) | 1)