PEP8 whitespace
This commit is contained in:
@@ -21,15 +21,20 @@ __all__ = [
|
||||
warnings.warn("eventlet.api is deprecated! Nearly everything in it has moved "
|
||||
"to the eventlet module.", DeprecationWarning, stacklevel=2)
|
||||
|
||||
|
||||
def get_hub(*a, **kw):
|
||||
warnings.warn("eventlet.api.get_hub has moved to eventlet.hubs.get_hub",
|
||||
DeprecationWarning, stacklevel=2)
|
||||
return hubs.get_hub(*a, **kw)
|
||||
|
||||
|
||||
def get_default_hub(*a, **kw):
|
||||
warnings.warn("eventlet.api.get_default_hub has moved to"
|
||||
" eventlet.hubs.get_default_hub",
|
||||
DeprecationWarning, stacklevel=2)
|
||||
return hubs.get_default_hub(*a, **kw)
|
||||
|
||||
|
||||
def use_hub(*a, **kw):
|
||||
warnings.warn("eventlet.api.use_hub has moved to eventlet.hubs.use_hub",
|
||||
DeprecationWarning, stacklevel=2)
|
||||
@@ -58,6 +63,7 @@ def tcp_listener(address, backlog=50):
|
||||
util.socket_bind_and_listen(socket, address, backlog=backlog)
|
||||
return socket
|
||||
|
||||
|
||||
def ssl_listener(address, certificate, private_key):
|
||||
"""Listen on the given (ip, port) *address* with a TCP socket that
|
||||
can do SSL. Primarily useful for unit tests, don't use in production.
|
||||
@@ -78,6 +84,7 @@ def ssl_listener(address, certificate, private_key):
|
||||
socket.listen(50)
|
||||
return socket
|
||||
|
||||
|
||||
def connect_tcp(address, localaddr=None):
|
||||
"""
|
||||
Create a TCP connection to address ``(host, port)`` and return the socket.
|
||||
|
@@ -4,6 +4,7 @@ from eventlet.support import greenlets as greenlet
|
||||
from eventlet import greenthread
|
||||
from eventlet.semaphore import Semaphore as LockType
|
||||
|
||||
|
||||
__patched__ = ['get_ident', 'start_new_thread', 'start_new', 'allocate_lock',
|
||||
'allocate', 'exit', 'interrupt_main', 'stack_size', '_local',
|
||||
'LockType', '_count']
|
||||
@@ -11,15 +12,18 @@ __patched__ = ['get_ident', 'start_new_thread', 'start_new', 'allocate_lock',
|
||||
error = __thread.error
|
||||
__threadcount = 0
|
||||
|
||||
|
||||
def _count():
|
||||
return __threadcount
|
||||
|
||||
|
||||
def get_ident(gr=None):
|
||||
if gr is None:
|
||||
return id(greenlet.getcurrent())
|
||||
else:
|
||||
return id(gr)
|
||||
|
||||
|
||||
def __thread_body(func, args, kwargs):
|
||||
global __threadcount
|
||||
__threadcount += 1
|
||||
@@ -28,22 +32,30 @@ def __thread_body(func, args, kwargs):
|
||||
finally:
|
||||
__threadcount -= 1
|
||||
|
||||
def start_new_thread(function, args=(), kwargs={}):
|
||||
|
||||
def start_new_thread(function, args=(), kwargs=None):
|
||||
kwargs = kwargs or {}
|
||||
g = greenthread.spawn_n(__thread_body, function, args, kwargs)
|
||||
return get_ident(g)
|
||||
|
||||
|
||||
start_new = start_new_thread
|
||||
|
||||
|
||||
def allocate_lock(*a):
|
||||
return LockType(1)
|
||||
|
||||
|
||||
allocate = allocate_lock
|
||||
|
||||
|
||||
def exit():
|
||||
raise greenlet.GreenletExit
|
||||
|
||||
|
||||
exit_thread = __thread.exit_thread
|
||||
|
||||
|
||||
def interrupt_main():
|
||||
curr = greenlet.getcurrent()
|
||||
if curr.parent and not curr.parent.dead:
|
||||
@@ -51,6 +63,7 @@ def interrupt_main():
|
||||
else:
|
||||
raise KeyboardInterrupt()
|
||||
|
||||
|
||||
if hasattr(__thread, 'stack_size'):
|
||||
__original_stack_size__ = __thread.stack_size
|
||||
def stack_size(size=None):
|
||||
|
@@ -13,6 +13,7 @@ EXC_MASK = select.POLLERR | select.POLLHUP
|
||||
READ_MASK = select.POLLIN | select.POLLPRI
|
||||
WRITE_MASK = select.POLLOUT
|
||||
|
||||
|
||||
class Hub(BaseHub):
|
||||
def __init__(self, clock=time.time):
|
||||
super(Hub, self).__init__(clock)
|
||||
@@ -111,4 +112,3 @@ class Hub(BaseHub):
|
||||
|
||||
if self.debug_blocking:
|
||||
self.block_detect_post()
|
||||
|
||||
|
@@ -44,6 +44,7 @@ def _signal_t2e():
|
||||
_wfile.write(_bytetosend)
|
||||
_wfile.flush()
|
||||
|
||||
|
||||
_reqq = None
|
||||
_rspq = None
|
||||
|
||||
|
Reference in New Issue
Block a user