Improve PEP8 conformance

This commit is contained in:
Jakub Stasiak
2014-11-11 23:36:45 +00:00
parent 272db8b402
commit 019ce17945
9 changed files with 39 additions and 20 deletions

View File

@@ -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)

View File

@@ -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.
"""

View File

@@ -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,7 +200,8 @@ class GreenSSLSocket(_original_sslsocket):
raise
if get_errno(e) == errno.EWOULDBLOCK:
try:
trampoline(self, read=True,
trampoline(
self, read=True,
timeout=self.gettimeout(), timeout_exc=timeout_exc('timed out'))
except IOClosed:
return b''
@@ -258,7 +261,8 @@ 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,
trampoline(
self, write=True,
timeout=end - time.time(), timeout_exc=timeout_exc('timed out'))
elif get_errno(exc) in CONNECT_SUCCESS:
return

View File

@@ -1,5 +1,6 @@
# -*- 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

View File

@@ -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 <http://en.wikipedia.org/wiki/Currying>`_ 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 <http://en.wikipedia.org/wiki/Currying>`_ 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

View File

@@ -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)

View File

@@ -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 <Queue.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 <Queue.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

View File

@@ -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

View File

@@ -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):