From 019ce17945cd3fac621726fbef7abff93b0c3ef9 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Tue, 11 Nov 2014 23:36:45 +0000 Subject: [PATCH] Improve PEP8 conformance --- eventlet/convenience.py | 6 +++++- eventlet/green/profile.py | 3 ++- eventlet/green/ssl.py | 14 +++++++++----- eventlet/green/zmq.py | 3 ++- eventlet/greenthread.py | 6 +++--- eventlet/hubs/hub.py | 3 ++- eventlet/queue.py | 18 ++++++++++++------ eventlet/websocket.py | 3 ++- tests/websocket_test.py | 3 ++- 9 files changed, 39 insertions(+), 20 deletions(-) diff --git a/eventlet/convenience.py b/eventlet/convenience.py index c329fcc..d634b2c 100644 --- a/eventlet/convenience.py +++ b/eventlet/convenience.py @@ -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 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. """ sock = socket.socket(family, socket.SOCK_STREAM) diff --git a/eventlet/green/profile.py b/eventlet/green/profile.py index 0b648ea..e323adc 100644 --- a/eventlet/green/profile.py +++ b/eventlet/green/profile.py @@ -23,7 +23,8 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # 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`. FIXME: No testcases for this module. """ diff --git a/eventlet/green/ssl.py b/eventlet/green/ssl.py index 0fdde5d..963fbdb 100644 --- a/eventlet/green/ssl.py +++ b/eventlet/green/ssl.py @@ -9,7 +9,9 @@ time = __import__('time') from eventlet.support import get_errno, PY33, six 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') socket = orig_socket.socket if sys.version_info >= (2, 7): @@ -198,8 +200,9 @@ class GreenSSLSocket(_original_sslsocket): raise if get_errno(e) == errno.EWOULDBLOCK: try: - trampoline(self, read=True, - timeout=self.gettimeout(), timeout_exc=timeout_exc('timed out')) + trampoline( + self, read=True, + timeout=self.gettimeout(), timeout_exc=timeout_exc('timed out')) except IOClosed: return b'' if get_errno(e) in SOCKET_CLOSED: @@ -258,8 +261,9 @@ class GreenSSLSocket(_original_sslsocket): real_connect(self, addr) except orig_socket.error as exc: if get_errno(exc) in CONNECT_ERR: - trampoline(self, write=True, - timeout=end - time.time(), timeout_exc=timeout_exc('timed out')) + trampoline( + self, write=True, + timeout=end - time.time(), timeout_exc=timeout_exc('timed out')) elif get_errno(exc) in CONNECT_SUCCESS: return else: diff --git a/eventlet/green/zmq.py b/eventlet/green/zmq.py index 3351f21..b08eabd 100644 --- a/eventlet/green/zmq.py +++ b/eventlet/green/zmq.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- -"""The :mod:`zmq` module wraps the :class:`Socket` and :class:`Context` found in :mod:`pyzmq ` to be non blocking +"""The :mod:`zmq` module wraps the :class:`Socket` and :class:`Context` +found in :mod:`pyzmq ` to be non blocking """ from __future__ import with_statement diff --git a/eventlet/greenthread.py b/eventlet/greenthread.py index f3ad92d..921d7a9 100644 --- a/eventlet/greenthread.py +++ b/eventlet/greenthread.py @@ -182,9 +182,9 @@ class GreenThread(greenlet.greenlet): def func(gt, [curried args/kwargs]): When the GreenThread finishes its run, it calls *func* with itself - and with the `curried arguments `_ supplied at link-time. If the function wants - to retrieve the result of the GreenThread, it should call wait() - on its first argument. + and with the `curried arguments `_ supplied + at link-time. If the function wants to retrieve the result of the GreenThread, + it should call wait() on its first argument. Note that *func* is called within execution context of the GreenThread, so it is possible to interfere with other linked diff --git a/eventlet/hubs/hub.py b/eventlet/hubs/hub.py index a49613e..8dda018 100644 --- a/eventlet/hubs/hub.py +++ b/eventlet/hubs/hub.py @@ -172,7 +172,8 @@ class BaseHub(object): "particular socket. Consider using a pools.Pool. " "If you do know what you're doing and want to disable " "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])) # store off the second listener in another structure self.secondaries[evtype].setdefault(fileno, []).append(listener) diff --git a/eventlet/queue.py b/eventlet/queue.py index b9e660a..5a82238 100644 --- a/eventlet/queue.py +++ b/eventlet/queue.py @@ -82,7 +82,9 @@ class Waiter(object): waiting = ' waiting' else: 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): """ @@ -195,7 +197,8 @@ class LightQueue(object): """Resizes the queue's maximum size. 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 self._schedule_unlock() self.maxsize = size @@ -219,7 +222,8 @@ class LightQueue(object): ``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): """Put an item into the queue. @@ -345,7 +349,9 @@ class LightQueue(object): putter.switch(putter) else: 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.switch(putter) else: @@ -404,8 +410,8 @@ class Queue(LightQueue): def task_done(self): '''Indicate that a formerly enqueued task is complete. Used by queue consumer threads. - For each :meth:`get ` used to fetch a task, a subsequent call to :meth:`task_done` tells the queue - that the processing on the task is complete. + For each :meth:`get ` used to fetch a task, a subsequent call to + :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 (meaning that a :meth:`task_done` call was received for every item that had been diff --git a/eventlet/websocket.py b/eventlet/websocket.py index 1fb33bb..8519c4f 100644 --- a/eventlet/websocket.py +++ b/eventlet/websocket.py @@ -256,7 +256,8 @@ class WebSocket(object): properties: 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 The value of the Websocket-Protocol header. origin diff --git a/tests/websocket_test.py b/tests/websocket_test.py index 1f7f1bf..4b2aa4f 100644 --- a/tests/websocket_test.py +++ b/tests/websocket_test.py @@ -169,7 +169,8 @@ class TestWebSocket(_TestBase): 'Connection: Upgrade', 'Sec-WebSocket-Origin: http://localhost:%s' % self.port, '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):