Improve PEP8 conformance
This commit is contained in:
@@ -30,7 +30,11 @@ def listen(addr, family=socket.AF_INET, backlog=50):
|
|||||||
|
|
||||||
:param addr: Address to listen on. For TCP sockets, this is a (host, port) tuple.
|
:param addr: Address to listen on. For TCP sockets, this is a (host, port) tuple.
|
||||||
:param family: Socket family, optional. See :mod:`socket` documentation for available families.
|
:param family: Socket family, optional. See :mod:`socket` documentation for available families.
|
||||||
:param backlog: The maximum number of queued connections. Should be at least 1; the maximum value is system-dependent.
|
:param backlog:
|
||||||
|
|
||||||
|
The maximum number of queued connections. Should be at least 1; the maximum
|
||||||
|
value is system-dependent.
|
||||||
|
|
||||||
:return: The listening green socket object.
|
:return: The listening green socket object.
|
||||||
"""
|
"""
|
||||||
sock = socket.socket(family, socket.SOCK_STREAM)
|
sock = socket.socket(family, socket.SOCK_STREAM)
|
||||||
|
|||||||
@@ -23,7 +23,8 @@
|
|||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
"""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
|
"""This module is API-equivalent to the standard library :mod:`profile` module
|
||||||
|
lbut 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`.
|
to profile Eventlet-based applications in preference to either :mod:`profile` or :mod:`cProfile`.
|
||||||
FIXME: No testcases for this module.
|
FIXME: No testcases for this module.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ time = __import__('time')
|
|||||||
|
|
||||||
from eventlet.support import get_errno, PY33, six
|
from eventlet.support import get_errno, PY33, six
|
||||||
from eventlet.hubs import trampoline, IOClosed
|
from eventlet.hubs import trampoline, IOClosed
|
||||||
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,
|
||||||
|
)
|
||||||
orig_socket = __import__('socket')
|
orig_socket = __import__('socket')
|
||||||
socket = orig_socket.socket
|
socket = orig_socket.socket
|
||||||
if sys.version_info >= (2, 7):
|
if sys.version_info >= (2, 7):
|
||||||
@@ -198,8 +200,9 @@ class GreenSSLSocket(_original_sslsocket):
|
|||||||
raise
|
raise
|
||||||
if get_errno(e) == errno.EWOULDBLOCK:
|
if get_errno(e) == errno.EWOULDBLOCK:
|
||||||
try:
|
try:
|
||||||
trampoline(self, read=True,
|
trampoline(
|
||||||
timeout=self.gettimeout(), timeout_exc=timeout_exc('timed out'))
|
self, read=True,
|
||||||
|
timeout=self.gettimeout(), timeout_exc=timeout_exc('timed out'))
|
||||||
except IOClosed:
|
except IOClosed:
|
||||||
return b''
|
return b''
|
||||||
if get_errno(e) in SOCKET_CLOSED:
|
if get_errno(e) in SOCKET_CLOSED:
|
||||||
@@ -258,8 +261,9 @@ class GreenSSLSocket(_original_sslsocket):
|
|||||||
real_connect(self, addr)
|
real_connect(self, addr)
|
||||||
except orig_socket.error as exc:
|
except orig_socket.error as exc:
|
||||||
if get_errno(exc) in CONNECT_ERR:
|
if get_errno(exc) in CONNECT_ERR:
|
||||||
trampoline(self, write=True,
|
trampoline(
|
||||||
timeout=end - time.time(), timeout_exc=timeout_exc('timed out'))
|
self, write=True,
|
||||||
|
timeout=end - time.time(), timeout_exc=timeout_exc('timed out'))
|
||||||
elif get_errno(exc) in CONNECT_SUCCESS:
|
elif get_errno(exc) in CONNECT_SUCCESS:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""The :mod:`zmq` module wraps the :class:`Socket` and :class:`Context` found in :mod:`pyzmq <zmq>` to be non blocking
|
"""The :mod:`zmq` module wraps the :class:`Socket` and :class:`Context`
|
||||||
|
found in :mod:`pyzmq <zmq>` to be non blocking
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|||||||
@@ -182,9 +182,9 @@ class GreenThread(greenlet.greenlet):
|
|||||||
def func(gt, [curried args/kwargs]):
|
def func(gt, [curried args/kwargs]):
|
||||||
|
|
||||||
When the GreenThread finishes its run, it calls *func* with itself
|
When the GreenThread finishes its run, it calls *func* with itself
|
||||||
and with the `curried arguments <http://en.wikipedia.org/wiki/Currying>`_ supplied at link-time. If the function wants
|
and with the `curried arguments <http://en.wikipedia.org/wiki/Currying>`_ supplied
|
||||||
to retrieve the result of the GreenThread, it should call wait()
|
at link-time. If the function wants to retrieve the result of the GreenThread,
|
||||||
on its first argument.
|
it should call wait() on its first argument.
|
||||||
|
|
||||||
Note that *func* is called within execution context of
|
Note that *func* is called within execution context of
|
||||||
the GreenThread, so it is possible to interfere with other linked
|
the GreenThread, so it is possible to interfere with other linked
|
||||||
|
|||||||
@@ -172,7 +172,8 @@ class BaseHub(object):
|
|||||||
"particular socket. Consider using a pools.Pool. "
|
"particular socket. Consider using a pools.Pool. "
|
||||||
"If you do know what you're doing and want to disable "
|
"If you do know what you're doing and want to disable "
|
||||||
"this error, call "
|
"this error, call "
|
||||||
"eventlet.debug.hub_prevent_multiple_readers(False) - MY THREAD=%s; THAT THREAD=%s" % (
|
"eventlet.debug.hub_prevent_multiple_readers(False) - MY THREAD=%s; "
|
||||||
|
"THAT THREAD=%s" % (
|
||||||
evtype, fileno, evtype, cb, bucket[fileno]))
|
evtype, fileno, evtype, cb, bucket[fileno]))
|
||||||
# store off the second listener in another structure
|
# store off the second listener in another structure
|
||||||
self.secondaries[evtype].setdefault(fileno, []).append(listener)
|
self.secondaries[evtype].setdefault(fileno, []).append(listener)
|
||||||
|
|||||||
@@ -82,7 +82,9 @@ class Waiter(object):
|
|||||||
waiting = ' waiting'
|
waiting = ' waiting'
|
||||||
else:
|
else:
|
||||||
waiting = ''
|
waiting = ''
|
||||||
return '<%s at %s%s greenlet=%r>' % (type(self).__name__, hex(id(self)), waiting, self.greenlet)
|
return '<%s at %s%s greenlet=%r>' % (
|
||||||
|
type(self).__name__, hex(id(self)), waiting, self.greenlet,
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""
|
"""
|
||||||
@@ -195,7 +197,8 @@ class LightQueue(object):
|
|||||||
"""Resizes the queue's maximum size.
|
"""Resizes the queue's maximum size.
|
||||||
|
|
||||||
If the size is increased, and there are putters waiting, they may be woken up."""
|
If the size is increased, and there are putters waiting, they may be woken up."""
|
||||||
if self.maxsize is not None and (size is None or size > self.maxsize): # None is not comparable in 3.x
|
# None is not comparable in 3.x
|
||||||
|
if self.maxsize is not None and (size is None or size > self.maxsize):
|
||||||
# Maybe wake some stuff up
|
# Maybe wake some stuff up
|
||||||
self._schedule_unlock()
|
self._schedule_unlock()
|
||||||
self.maxsize = size
|
self.maxsize = size
|
||||||
@@ -219,7 +222,8 @@ class LightQueue(object):
|
|||||||
|
|
||||||
``Queue(None)`` is never full.
|
``Queue(None)`` is never full.
|
||||||
"""
|
"""
|
||||||
return self.maxsize is not None and self.qsize() >= self.maxsize # None is not comparable in 3.x
|
# None is not comparable in 3.x
|
||||||
|
return self.maxsize is not None and self.qsize() >= self.maxsize
|
||||||
|
|
||||||
def put(self, item, block=True, timeout=None):
|
def put(self, item, block=True, timeout=None):
|
||||||
"""Put an item into the queue.
|
"""Put an item into the queue.
|
||||||
@@ -345,7 +349,9 @@ class LightQueue(object):
|
|||||||
putter.switch(putter)
|
putter.switch(putter)
|
||||||
else:
|
else:
|
||||||
self.putters.add(putter)
|
self.putters.add(putter)
|
||||||
elif self.putters and (self.getters or self.maxsize is None or self.qsize() < self.maxsize):
|
elif self.putters and (self.getters or
|
||||||
|
self.maxsize is None or
|
||||||
|
self.qsize() < self.maxsize):
|
||||||
putter = self.putters.pop()
|
putter = self.putters.pop()
|
||||||
putter.switch(putter)
|
putter.switch(putter)
|
||||||
else:
|
else:
|
||||||
@@ -404,8 +410,8 @@ class Queue(LightQueue):
|
|||||||
|
|
||||||
def task_done(self):
|
def task_done(self):
|
||||||
'''Indicate that a formerly enqueued task is complete. Used by queue consumer threads.
|
'''Indicate that a formerly enqueued task is complete. Used by queue consumer threads.
|
||||||
For each :meth:`get <Queue.get>` used to fetch a task, a subsequent call to :meth:`task_done` tells the queue
|
For each :meth:`get <Queue.get>` used to fetch a task, a subsequent call to
|
||||||
that the processing on the task is complete.
|
:meth:`task_done` tells the queue that the processing on the task is complete.
|
||||||
|
|
||||||
If a :meth:`join` is currently blocking, it will resume when all items have been processed
|
If a :meth:`join` is currently blocking, it will resume when all items have been processed
|
||||||
(meaning that a :meth:`task_done` call was received for every item that had been
|
(meaning that a :meth:`task_done` call was received for every item that had been
|
||||||
|
|||||||
@@ -256,7 +256,8 @@ class WebSocket(object):
|
|||||||
properties:
|
properties:
|
||||||
|
|
||||||
path
|
path
|
||||||
The path value of the request. This is the same as the WSGI PATH_INFO variable, but more convenient.
|
The path value of the request. This is the same as the WSGI PATH_INFO variable,
|
||||||
|
but more convenient.
|
||||||
protocol
|
protocol
|
||||||
The value of the Websocket-Protocol header.
|
The value of the Websocket-Protocol header.
|
||||||
origin
|
origin
|
||||||
|
|||||||
@@ -169,7 +169,8 @@ class TestWebSocket(_TestBase):
|
|||||||
'Connection: Upgrade',
|
'Connection: Upgrade',
|
||||||
'Sec-WebSocket-Origin: http://localhost:%s' % self.port,
|
'Sec-WebSocket-Origin: http://localhost:%s' % self.port,
|
||||||
'Sec-WebSocket-Protocol: ws',
|
'Sec-WebSocket-Protocol: ws',
|
||||||
'Sec-WebSocket-Location: ws://localhost:%s/echo?query_string\r\n\r\n8jKS\'y:G*Co,Wxa-' % self.port,
|
'Sec-WebSocket-Location: '
|
||||||
|
'ws://localhost:%s/echo?query_string\r\n\r\n8jKS\'y:G*Co,Wxa-' % self.port,
|
||||||
]))
|
]))
|
||||||
|
|
||||||
def test_empty_query_string(self):
|
def test_empty_query_string(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user