Commit 1bb128b8 authored by Denis Bilenko's avatar Denis Bilenko

pep8

parent d70a3fd1
......@@ -115,4 +115,3 @@ if __name__ == '__main__':
print 'USAGE: %s PORT' % sys.argv[0]
else:
BackdoorServer(('127.0.0.1', int(sys.argv[1]))).serve_forever()
......@@ -196,4 +196,3 @@ def _tcp_listener(address, backlog=50, reuse_addr=None):
sock.listen(backlog)
sock.setblocking(0)
return sock
......@@ -232,4 +232,3 @@ class RLock(object):
def _is_owned(self):
return self._owner is getcurrent()
......@@ -36,7 +36,7 @@ class DNSError(gaierror):
"""
def __init__(self, *args):
if len(args)==1:
if len(args) == 1:
code = args[0]
gaierror.__init__(self, code, core.dns_err_to_string(code))
else:
......
......@@ -320,4 +320,3 @@ def waitall(events):
finally:
for event in events:
event.unlink(put)
......@@ -228,7 +228,7 @@ class Greenlet(greenlet):
# the result was not set and the links weren't notified. let's do it here.
# checking that self.dead is true is essential, because the exception raised by
# throw() could have been cancelled by the greenlet's function.
if len(args)==1:
if len(args) == 1:
arg = args[0]
#if isinstance(arg, type):
if type(arg) is type(Exception):
......@@ -614,4 +614,3 @@ def getfuncname(func):
_NONE = Exception("Neither exception nor value")
......@@ -47,4 +47,3 @@ class HTTPServer(BaseServer):
def stop_accepting(self):
self.http = None
......@@ -100,8 +100,9 @@ def _wrap_signal_handler(handler, args, kwargs):
except:
core.active_event(MAIN.throw, *sys.exc_info())
def signal(signalnum, handler, *args, **kwargs):
return core.signal(signalnum, lambda : spawn_raw(_wrap_signal_handler, handler, args, kwargs))
return core.signal(signalnum, lambda: spawn_raw(_wrap_signal_handler, handler, args, kwargs))
if _original_fork is not None:
......@@ -329,8 +330,8 @@ class Waiter(object):
class _NONE(object):
"A special thingy you must never pass to any of gevent API"
__slots__ = []
def __repr__(self):
return '<_NONE>'
_NONE = _NONE()
......@@ -132,6 +132,7 @@ from gevent.coros import RLock
__all__ = ["local"]
class _localbase(object):
__slots__ = '_local__args', '_local__lock', '_local__dicts'
......
......@@ -26,7 +26,7 @@ class Group(object):
greenlet_class = Greenlet
def __init__(self, *args):
assert len(args)<=1, args
assert len(args) <= 1, args
self.greenlets = set(*args)
if args:
for greenlet in args[0]:
......@@ -315,4 +315,3 @@ class pass_value(object):
def __getattr__(self, item):
assert item != 'callback'
return getattr(self.callback, item)
......@@ -19,14 +19,11 @@ __all__ = ['WSGIHandler', 'WSGIServer']
MAX_REQUEST_LINE = 8192
# Weekday and month names for HTTP date/time formatting; always English!
_WEEKDAYNAME = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
_MONTHNAME = [None, # Dummy so we can use 1-based month numbers
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
_INTERNAL_ERROR_STATUS = '500 Internal Server Error'
_INTERNAL_ERROR_BODY = 'Internal Server Error'
_INTERNAL_ERROR_HEADERS = [('Content-Type', 'text/plain'),
......@@ -34,9 +31,9 @@ _INTERNAL_ERROR_HEADERS = [('Content-Type', 'text/plain'),
('Content-Length', str(len(_INTERNAL_ERROR_BODY)))]
_REQUEST_TOO_LONG_RESPONSE = "HTTP/1.0 414 Request URI Too Long\r\nConnection: close\r\nContent-length: 0\r\n\r\n"
_BAD_REQUEST_RESPONSE = "HTTP/1.0 400 Bad Request\r\nConnection: close\r\nContent-length: 0\r\n\r\n"
_CONTINUE_RESPONSE = "HTTP/1.1 100 Continue\r\n\r\n"
def format_date_time(timestamp):
year, month, day, hh, mm, ss, wd, _y, _z = time.gmtime(timestamp)
return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (_WEEKDAYNAME[wd], day, _MONTHNAME[month], year, hh, mm, ss)
......
......@@ -315,4 +315,3 @@ class JoinableQueue(Queue):
unfinished tasks drops to zero, :meth:`join` unblocks.
'''
self._cond.wait()
......@@ -74,7 +74,7 @@ def join(greenlet, polling_period=0.2):
"""Wait for a greenlet to finish by polling its status"""
delay = 0.002
while not greenlet.dead:
delay = min(polling_period, delay*2)
delay = min(polling_period, delay * 2)
sleep(delay)
......@@ -85,8 +85,7 @@ def joinall(greenlets, polling_period=0.2):
current += 1
delay = 0.002
while current < len(greenlets):
delay = min(polling_period, delay*2)
delay = min(polling_period, delay * 2)
sleep(delay)
while current < len(greenlets) and greenlets[current].dead:
current += 1
......@@ -65,4 +65,3 @@ def select(rlist, wlist, xlist, timeout=None):
for evt in allevents:
evt.cancel()
timeout.cancel()
......@@ -114,7 +114,7 @@ class StreamServer(BaseServer):
try:
client_socket, address = self.socket.accept()
except socket.error, err:
if err[0]==errno.EAGAIN:
if err[0] == errno.EAGAIN:
sys.exc_clear()
return
raise
......@@ -144,7 +144,7 @@ class StreamServer(BaseServer):
if self.delay >= 0:
self.stop_accepting()
self._start_accepting_timer = core.timer(self.delay, self.start_accepting)
self.delay = min(self.max_delay, self.delay*2)
self.delay = min(self.max_delay, self.delay * 2)
sys.exc_clear()
def is_fatal_error(self, ex):
......@@ -162,4 +162,3 @@ def _import_sslold_wrap_socket():
return wrap_socket
except ImportError:
pass
......@@ -12,6 +12,7 @@ __all__ = ['ssl', 'sslerror']
try:
sslerror = __socket__.sslerror
except AttributeError:
class sslerror(error):
pass
......@@ -185,4 +186,3 @@ def wrap_socket(sock, keyfile=None, certfile=None,
if locals()[arg] is not None:
raise TypeError('To use argument %r install ssl package: http://pypi.python.org/pypi/ssl' % arg)
return ssl(sock, keyfile=keyfile, certfile=certfile)
......@@ -23,6 +23,7 @@ __all__ = ['Timeout',
try:
BaseException
except NameError: # Python < 2.5
class BaseException:
# not subclassing from object() intentionally, because in
# that case "raise Timeout" fails with TypeError.
......@@ -196,4 +197,3 @@ def with_timeout(seconds, function, *args, **kwds):
raise
finally:
timeout.cancel()
# Copyright (c) 2009 Denis Bilenko. See LICENSE for details.
__all__ = ['wrap_errors', 'lazy_property']
class wrap_errors(object):
"""Helper to make function return an exception, rather than raise it.
......@@ -62,4 +63,3 @@ class lazy_property(object):
value = self._calculate(obj)
setattr(obj, self._calculate.func_name, value)
return value
......@@ -66,7 +66,6 @@ class _ErrorFormatter(object):
return cls(WinError, FormatMessage, errorTab)
fromEnvironment = classmethod(fromEnvironment)
def formatError(self, errorcode):
"""
Returns the string associated with a Windows error message, such as the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment