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

pep8

parent d70a3fd1
...@@ -33,7 +33,7 @@ __all__ = ['Greenlet', ...@@ -33,7 +33,7 @@ __all__ = ['Greenlet',
import sys import sys
if sys.platform == 'win32': if sys.platform == 'win32':
__import__('socket') # trigger WSAStartup call __import__('socket') # trigger WSAStartup call
del sys del sys
......
...@@ -86,7 +86,7 @@ class SocketConsole(Greenlet): ...@@ -86,7 +86,7 @@ class SocketConsole(Greenlet):
try: try:
console = InteractiveConsole(self.locals) console = InteractiveConsole(self.locals)
console.interact() console.interact()
except SystemExit: # raised by quit() except SystemExit: # raised by quit()
pass pass
finally: finally:
self.switch_out() self.switch_out()
...@@ -115,4 +115,3 @@ if __name__ == '__main__': ...@@ -115,4 +115,3 @@ if __name__ == '__main__':
print 'USAGE: %s PORT' % sys.argv[0] print 'USAGE: %s PORT' % sys.argv[0]
else: else:
BackdoorServer(('127.0.0.1', int(sys.argv[1]))).serve_forever() BackdoorServer(('127.0.0.1', int(sys.argv[1]))).serve_forever()
...@@ -196,4 +196,3 @@ def _tcp_listener(address, backlog=50, reuse_addr=None): ...@@ -196,4 +196,3 @@ def _tcp_listener(address, backlog=50, reuse_addr=None):
sock.listen(backlog) sock.listen(backlog)
sock.setblocking(0) sock.setblocking(0)
return sock return sock
...@@ -15,7 +15,7 @@ class Semaphore(object): ...@@ -15,7 +15,7 @@ class Semaphore(object):
"""A semaphore manages a counter representing the number of release() calls minus the number of acquire() calls, """A semaphore manages a counter representing the number of release() calls minus the number of acquire() calls,
plus an initial value. The acquire() method blocks if necessary until it can return without making the counter plus an initial value. The acquire() method blocks if necessary until it can return without making the counter
negative. negative.
If not given, value defaults to 1.""" If not given, value defaults to 1."""
def __init__(self, value=1): def __init__(self, value=1):
...@@ -232,4 +232,3 @@ class RLock(object): ...@@ -232,4 +232,3 @@ class RLock(object):
def _is_owned(self): def _is_owned(self):
return self._owner is getcurrent() return self._owner is getcurrent()
...@@ -36,7 +36,7 @@ class DNSError(gaierror): ...@@ -36,7 +36,7 @@ class DNSError(gaierror):
""" """
def __init__(self, *args): def __init__(self, *args):
if len(args)==1: if len(args) == 1:
code = args[0] code = args[0]
gaierror.__init__(self, code, core.dns_err_to_string(code)) gaierror.__init__(self, code, core.dns_err_to_string(code))
else: else:
......
...@@ -30,8 +30,8 @@ class Event(object): ...@@ -30,8 +30,8 @@ class Event(object):
"""Return true if and only if the internal flag is true.""" """Return true if and only if the internal flag is true."""
return self._flag return self._flag
isSet = is_set # makes it a better drop-in replacement for threading.Event isSet = is_set # makes it a better drop-in replacement for threading.Event
ready = is_set # makes it compatible with AsyncResult and Greenlet (for example in wait()) ready = is_set # makes it compatible with AsyncResult and Greenlet (for example in wait())
def set(self): def set(self):
"""Set the internal flag to true. All greenlets waiting for it to become true are awakened. """Set the internal flag to true. All greenlets waiting for it to become true are awakened.
...@@ -92,7 +92,7 @@ class Event(object): ...@@ -92,7 +92,7 @@ class Event(object):
raise TypeError('Expected callable: %r' % (callback, )) raise TypeError('Expected callable: %r' % (callback, ))
self._links.append(callback) self._links.append(callback)
if self._flag: if self._flag:
core.active_event(self._notify_links, list(self._links)) # XXX just pass [callback] core.active_event(self._notify_links, list(self._links)) # XXX just pass [callback]
def unlink(self, callback): def unlink(self, callback):
"""Remove the callback set by :meth:`rawlink`""" """Remove the callback set by :meth:`rawlink`"""
...@@ -104,7 +104,7 @@ class Event(object): ...@@ -104,7 +104,7 @@ class Event(object):
def _notify_links(self, links): def _notify_links(self, links):
assert getcurrent() is get_hub() assert getcurrent() is get_hub()
for link in links: for link in links:
if link in self._links: # check that link was not notified yet and was not removed by the client if link in self._links: # check that link was not notified yet and was not removed by the client
try: try:
link(self) link(self)
except: except:
...@@ -320,4 +320,3 @@ def waitall(events): ...@@ -320,4 +320,3 @@ def waitall(events):
finally: finally:
for event in events: for event in events:
event.unlink(put) event.unlink(put)
...@@ -228,7 +228,7 @@ class Greenlet(greenlet): ...@@ -228,7 +228,7 @@ class Greenlet(greenlet):
# the result was not set and the links weren't notified. let's do it here. # 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 # checking that self.dead is true is essential, because the exception raised by
# throw() could have been cancelled by the greenlet's function. # throw() could have been cancelled by the greenlet's function.
if len(args)==1: if len(args) == 1:
arg = args[0] arg = args[0]
#if isinstance(arg, type): #if isinstance(arg, type):
if type(arg) is type(Exception): if type(arg) is type(Exception):
...@@ -614,4 +614,3 @@ def getfuncname(func): ...@@ -614,4 +614,3 @@ def getfuncname(func):
_NONE = Exception("Neither exception nor value") _NONE = Exception("Neither exception nor value")
...@@ -47,4 +47,3 @@ class HTTPServer(BaseServer): ...@@ -47,4 +47,3 @@ class HTTPServer(BaseServer):
def stop_accepting(self): def stop_accepting(self):
self.http = None self.http = None
...@@ -100,8 +100,9 @@ def _wrap_signal_handler(handler, args, kwargs): ...@@ -100,8 +100,9 @@ def _wrap_signal_handler(handler, args, kwargs):
except: except:
core.active_event(MAIN.throw, *sys.exc_info()) core.active_event(MAIN.throw, *sys.exc_info())
def signal(signalnum, handler, *args, **kwargs): 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: if _original_fork is not None:
...@@ -169,7 +170,7 @@ class Hub(greenlet): ...@@ -169,7 +170,7 @@ class Hub(greenlet):
try: try:
self.keyboard_interrupt_signal = signal(2, core.active_event, MAIN.throw, KeyboardInterrupt) self.keyboard_interrupt_signal = signal(2, core.active_event, MAIN.throw, KeyboardInterrupt)
except IOError: except IOError:
pass # no signal() on windows pass # no signal() on windows
try: try:
loop_count = 0 loop_count = 0
while True: while True:
...@@ -204,7 +205,7 @@ class Hub(greenlet): ...@@ -204,7 +205,7 @@ class Hub(greenlet):
try: try:
self.switch() self.switch()
except DispatchExit, ex: except DispatchExit, ex:
if ex.code == 1: # no more events registered? if ex.code == 1: # no more events registered?
return return
raise raise
...@@ -320,7 +321,7 @@ class Waiter(object): ...@@ -320,7 +321,7 @@ class Waiter(object):
finally: finally:
self.greenlet = None self.greenlet = None
wait = get # XXX backward compatibility; will be removed in the next release wait = get # XXX backward compatibility; will be removed in the next release
# can also have a debugging version, that wraps the value in a tuple (self, value) in switch() # can also have a debugging version, that wraps the value in a tuple (self, value) in switch()
# and unwraps it in wait() thus checking that switch() was indeed called # and unwraps it in wait() thus checking that switch() was indeed called
...@@ -329,8 +330,8 @@ class Waiter(object): ...@@ -329,8 +330,8 @@ class Waiter(object):
class _NONE(object): class _NONE(object):
"A special thingy you must never pass to any of gevent API" "A special thingy you must never pass to any of gevent API"
__slots__ = [] __slots__ = []
def __repr__(self): def __repr__(self):
return '<_NONE>' return '<_NONE>'
_NONE = _NONE() _NONE = _NONE()
...@@ -132,6 +132,7 @@ from gevent.coros import RLock ...@@ -132,6 +132,7 @@ from gevent.coros import RLock
__all__ = ["local"] __all__ = ["local"]
class _localbase(object): class _localbase(object):
__slots__ = '_local__args', '_local__lock', '_local__dicts' __slots__ = '_local__args', '_local__lock', '_local__dicts'
......
...@@ -26,7 +26,7 @@ class Group(object): ...@@ -26,7 +26,7 @@ class Group(object):
greenlet_class = Greenlet greenlet_class = Greenlet
def __init__(self, *args): def __init__(self, *args):
assert len(args)<=1, args assert len(args) <= 1, args
self.greenlets = set(*args) self.greenlets = set(*args)
if args: if args:
for greenlet in args[0]: for greenlet in args[0]:
...@@ -40,7 +40,7 @@ class Group(object): ...@@ -40,7 +40,7 @@ class Group(object):
try: try:
classname = self.__class__.__name__ classname = self.__class__.__name__
except AttributeError: except AttributeError:
classname = 'Group' # XXX check if 2.4 really uses this line classname = 'Group' # XXX check if 2.4 really uses this line
return '<%s at %s %s>' % (classname, hex(id(self)), self.greenlets) return '<%s at %s %s>' % (classname, hex(id(self)), self.greenlets)
def __len__(self): def __len__(self):
...@@ -183,7 +183,7 @@ class Group(object): ...@@ -183,7 +183,7 @@ class Group(object):
def imap(self, func, iterable): def imap(self, func, iterable):
"""An equivalent of itertools.imap() """An equivalent of itertools.imap()
**TODO**: Fix this. **TODO**: Fix this.
""" """
return iter(self.map(func, iterable)) return iter(self.map(func, iterable))
...@@ -191,7 +191,7 @@ class Group(object): ...@@ -191,7 +191,7 @@ class Group(object):
def imap_unordered(self, func, iterable): def imap_unordered(self, func, iterable):
"""The same as imap() except that the ordering of the results from the """The same as imap() except that the ordering of the results from the
returned iterator should be considered arbitrary. returned iterator should be considered arbitrary.
**TODO**: Fix this. **TODO**: Fix this.
""" """
return iter(self.map(func, iterable)) return iter(self.map(func, iterable))
...@@ -203,7 +203,7 @@ class Group(object): ...@@ -203,7 +203,7 @@ class Group(object):
pass pass
GreenletSet = Group # the old name; will be deprecated in the future GreenletSet = Group # the old name; will be deprecated in the future
class Pool(Group): class Pool(Group):
...@@ -315,4 +315,3 @@ class pass_value(object): ...@@ -315,4 +315,3 @@ class pass_value(object):
def __getattr__(self, item): def __getattr__(self, item):
assert item != 'callback' assert item != 'callback'
return getattr(self.callback, item) return getattr(self.callback, item)
...@@ -19,14 +19,11 @@ __all__ = ['WSGIHandler', 'WSGIServer'] ...@@ -19,14 +19,11 @@ __all__ = ['WSGIHandler', 'WSGIServer']
MAX_REQUEST_LINE = 8192 MAX_REQUEST_LINE = 8192
# Weekday and month names for HTTP date/time formatting; always English! # Weekday and month names for HTTP date/time formatting; always English!
_WEEKDAYNAME = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] _WEEKDAYNAME = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
_MONTHNAME = [None, # Dummy so we can use 1-based month numbers _MONTHNAME = [None, # Dummy so we can use 1-based month numbers
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
_INTERNAL_ERROR_STATUS = '500 Internal Server Error' _INTERNAL_ERROR_STATUS = '500 Internal Server Error'
_INTERNAL_ERROR_BODY = 'Internal Server Error' _INTERNAL_ERROR_BODY = 'Internal Server Error'
_INTERNAL_ERROR_HEADERS = [('Content-Type', 'text/plain'), _INTERNAL_ERROR_HEADERS = [('Content-Type', 'text/plain'),
...@@ -34,9 +31,9 @@ _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)))] ('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" _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" _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" _CONTINUE_RESPONSE = "HTTP/1.1 100 Continue\r\n\r\n"
def format_date_time(timestamp): def format_date_time(timestamp):
year, month, day, hh, mm, ss, wd, _y, _z = time.gmtime(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) return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (_WEEKDAYNAME[wd], day, _MONTHNAME[month], year, hh, mm, ss)
...@@ -184,7 +181,7 @@ class WSGIHandler(object): ...@@ -184,7 +181,7 @@ class WSGIHandler(object):
version = self.request_version version = self.request_version
if not version.startswith("HTTP/"): if not version.startswith("HTTP/"):
return False return False
version = tuple(int(x) for x in version[5:].split(".")) # "HTTP/" version = tuple(int(x) for x in version[5:].split(".")) # "HTTP/"
if version[1] < 0 or version < (0, 9) or version >= (2, 0): if version[1] < 0 or version < (0, 9) or version >= (2, 0):
return False return False
return True return True
...@@ -299,7 +296,7 @@ class WSGIHandler(object): ...@@ -299,7 +296,7 @@ class WSGIHandler(object):
if self.rfile.closed: if self.rfile.closed:
return return
return True # read more requests return True # read more requests
def write(self, data): def write(self, data):
towrite = [] towrite = []
......
...@@ -208,7 +208,7 @@ class Queue(object): ...@@ -208,7 +208,7 @@ class Queue(object):
getter = self.getters.pop() getter = self.getters.pop()
if getter: if getter:
item = putter.item item = putter.item
putter.item = _NONE # this makes greenlet calling put() not to call _put() again putter.item = _NONE # this makes greenlet calling put() not to call _put() again
self._put(item) self._put(item)
item = self._get() item = self._get()
getter.switch(item) getter.switch(item)
...@@ -221,7 +221,7 @@ class Queue(object): ...@@ -221,7 +221,7 @@ class Queue(object):
else: else:
break break
finally: finally:
self._event_unlock = None # QQQ maybe it's possible to obtain this info from libevent? self._event_unlock = None # QQQ maybe it's possible to obtain this info from libevent?
# i.e. whether this event is pending _OR_ currently executing # i.e. whether this event is pending _OR_ currently executing
# testcase: 2 greenlets: while True: q.put(q.get()) - nothing else has a change to execute # testcase: 2 greenlets: while True: q.put(q.get()) - nothing else has a change to execute
# to avoid this, schedule unlock with timer(0, ...) once in a while # to avoid this, schedule unlock with timer(0, ...) once in a while
...@@ -315,4 +315,3 @@ class JoinableQueue(Queue): ...@@ -315,4 +315,3 @@ class JoinableQueue(Queue):
unfinished tasks drops to zero, :meth:`join` unblocks. unfinished tasks drops to zero, :meth:`join` unblocks.
''' '''
self._cond.wait() self._cond.wait()
...@@ -74,7 +74,7 @@ def join(greenlet, polling_period=0.2): ...@@ -74,7 +74,7 @@ def join(greenlet, polling_period=0.2):
"""Wait for a greenlet to finish by polling its status""" """Wait for a greenlet to finish by polling its status"""
delay = 0.002 delay = 0.002
while not greenlet.dead: while not greenlet.dead:
delay = min(polling_period, delay*2) delay = min(polling_period, delay * 2)
sleep(delay) sleep(delay)
...@@ -85,8 +85,7 @@ def joinall(greenlets, polling_period=0.2): ...@@ -85,8 +85,7 @@ def joinall(greenlets, polling_period=0.2):
current += 1 current += 1
delay = 0.002 delay = 0.002
while current < len(greenlets): while current < len(greenlets):
delay = min(polling_period, delay*2) delay = min(polling_period, delay * 2)
sleep(delay) sleep(delay)
while current < len(greenlets) and greenlets[current].dead: while current < len(greenlets) and greenlets[current].dead:
current += 1 current += 1
...@@ -65,4 +65,3 @@ def select(rlist, wlist, xlist, timeout=None): ...@@ -65,4 +65,3 @@ def select(rlist, wlist, xlist, timeout=None):
for evt in allevents: for evt in allevents:
evt.cancel() evt.cancel()
timeout.cancel() timeout.cancel()
...@@ -114,7 +114,7 @@ class StreamServer(BaseServer): ...@@ -114,7 +114,7 @@ class StreamServer(BaseServer):
try: try:
client_socket, address = self.socket.accept() client_socket, address = self.socket.accept()
except socket.error, err: except socket.error, err:
if err[0]==errno.EAGAIN: if err[0] == errno.EAGAIN:
sys.exc_clear() sys.exc_clear()
return return
raise raise
...@@ -144,7 +144,7 @@ class StreamServer(BaseServer): ...@@ -144,7 +144,7 @@ class StreamServer(BaseServer):
if self.delay >= 0: if self.delay >= 0:
self.stop_accepting() self.stop_accepting()
self._start_accepting_timer = core.timer(self.delay, self.start_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() sys.exc_clear()
def is_fatal_error(self, ex): def is_fatal_error(self, ex):
...@@ -162,4 +162,3 @@ def _import_sslold_wrap_socket(): ...@@ -162,4 +162,3 @@ def _import_sslold_wrap_socket():
return wrap_socket return wrap_socket
except ImportError: except ImportError:
pass pass
...@@ -12,6 +12,7 @@ __all__ = ['ssl', 'sslerror'] ...@@ -12,6 +12,7 @@ __all__ = ['ssl', 'sslerror']
try: try:
sslerror = __socket__.sslerror sslerror = __socket__.sslerror
except AttributeError: except AttributeError:
class sslerror(error): class sslerror(error):
pass pass
...@@ -176,7 +177,7 @@ def wrap_socket(sock, keyfile=None, certfile=None, ...@@ -176,7 +177,7 @@ def wrap_socket(sock, keyfile=None, certfile=None,
do_handshake_on_connect=None, do_handshake_on_connect=None,
suppress_ragged_eofs=None): suppress_ragged_eofs=None):
"""Create a new :class:`SSLObject` instance. """Create a new :class:`SSLObject` instance.
For compatibility with :mod:`gevent.ssl` the function accepts all the arguments that :func:`gevent.ssl.wrap_socket` For compatibility with :mod:`gevent.ssl` the function accepts all the arguments that :func:`gevent.ssl.wrap_socket`
accepts. However, it only understands what *sock*, *keyfile* and *certfile* mean, so it will raise accepts. However, it only understands what *sock*, *keyfile* and *certfile* mean, so it will raise
:exc:`ImportError` if you pass anything else. :exc:`ImportError` if you pass anything else.
...@@ -185,4 +186,3 @@ def wrap_socket(sock, keyfile=None, certfile=None, ...@@ -185,4 +186,3 @@ def wrap_socket(sock, keyfile=None, certfile=None,
if locals()[arg] is not None: if locals()[arg] is not None:
raise TypeError('To use argument %r install ssl package: http://pypi.python.org/pypi/ssl' % arg) raise TypeError('To use argument %r install ssl package: http://pypi.python.org/pypi/ssl' % arg)
return ssl(sock, keyfile=keyfile, certfile=certfile) return ssl(sock, keyfile=keyfile, certfile=certfile)
...@@ -22,7 +22,8 @@ __all__ = ['Timeout', ...@@ -22,7 +22,8 @@ __all__ = ['Timeout',
try: try:
BaseException BaseException
except NameError: # Python < 2.5 except NameError: # Python < 2.5
class BaseException: class BaseException:
# not subclassing from object() intentionally, because in # not subclassing from object() intentionally, because in
# that case "raise Timeout" fails with TypeError. # that case "raise Timeout" fails with TypeError.
...@@ -35,7 +36,7 @@ class Timeout(BaseException): ...@@ -35,7 +36,7 @@ class Timeout(BaseException):
timeout = Timeout(seconds, exception) timeout = Timeout(seconds, exception)
timeout.start() timeout.start()
try: try:
... # exception will be raised here, after *seconds* passed since start() call ... # exception will be raised here, after *seconds* passed since start() call
finally: finally:
timeout.cancel() timeout.cancel()
...@@ -50,7 +51,7 @@ class Timeout(BaseException): ...@@ -50,7 +51,7 @@ class Timeout(BaseException):
For Python 2.5 and newer ``with`` statement can be used:: For Python 2.5 and newer ``with`` statement can be used::
with Timeout(seconds, exception) as timeout: with Timeout(seconds, exception) as timeout:
pass # ... code block ... pass # ... code block ...
This is equivalent to try/finally block above with one additional feature: This is equivalent to try/finally block above with one additional feature:
if *exception* is ``False``, the timeout is still raised, but context manager if *exception* is ``False``, the timeout is still raised, but context manager
...@@ -62,9 +63,9 @@ class Timeout(BaseException): ...@@ -62,9 +63,9 @@ class Timeout(BaseException):
with Timeout(5, False): with Timeout(5, False):
data = mysock.makefile().readline() data = mysock.makefile().readline()
if data is None: if data is None:
... # 5 seconds passed without reading a line ... # 5 seconds passed without reading a line
else: else:
... # a line was read within 5 seconds ... # a line was read within 5 seconds
Note that, if ``readline()`` above catches and doesn't re-raise :class:`BaseException` Note that, if ``readline()`` above catches and doesn't re-raise :class:`BaseException`
(for example, with ``except:``), then your timeout is screwed. (for example, with ``except:``), then your timeout is screwed.
...@@ -90,11 +91,11 @@ class Timeout(BaseException): ...@@ -90,11 +91,11 @@ class Timeout(BaseException):
def start(self): def start(self):
"""Schedule the timeout.""" """Schedule the timeout."""
assert not self.pending, '%r is already started; to restart it, cancel it first' % self assert not self.pending, '%r is already started; to restart it, cancel it first' % self
if self.seconds is None: # "fake" timeout (never expires) if self.seconds is None: # "fake" timeout (never expires)
self.timer = None self.timer = None
elif self.exception is None or self.exception is False: # timeout that raises self elif self.exception is None or self.exception is False: # timeout that raises self
self.timer = core.timer(self.seconds, getcurrent().throw, self) self.timer = core.timer(self.seconds, getcurrent().throw, self)
else: # regular timeout with user-provided exception else: # regular timeout with user-provided exception
self.timer = core.timer(self.seconds, getcurrent().throw, self.exception) self.timer = core.timer(self.seconds, getcurrent().throw, self.exception)
@classmethod @classmethod
...@@ -133,7 +134,7 @@ class Timeout(BaseException): ...@@ -133,7 +134,7 @@ class Timeout(BaseException):
def __repr__(self): def __repr__(self):
try: try:
classname = self.__class__.__name__ classname = self.__class__.__name__
except AttributeError: # Python < 2.5 except AttributeError: # Python < 2.5
classname = 'Timeout' classname = 'Timeout'
if self.pending: if self.pending:
pending = ' pending' pending = ' pending'
...@@ -196,4 +197,3 @@ def with_timeout(seconds, function, *args, **kwds): ...@@ -196,4 +197,3 @@ def with_timeout(seconds, function, *args, **kwds):
raise raise
finally: finally:
timeout.cancel() timeout.cancel()
# Copyright (c) 2009 Denis Bilenko. See LICENSE for details. # Copyright (c) 2009 Denis Bilenko. See LICENSE for details.
__all__ = ['wrap_errors', 'lazy_property'] __all__ = ['wrap_errors', 'lazy_property']
class wrap_errors(object): class wrap_errors(object):
"""Helper to make function return an exception, rather than raise it. """Helper to make function return an exception, rather than raise it.
...@@ -62,4 +63,3 @@ class lazy_property(object): ...@@ -62,4 +63,3 @@ class lazy_property(object):
value = self._calculate(obj) value = self._calculate(obj)
setattr(obj, self._calculate.func_name, value) setattr(obj, self._calculate.func_name, value)
return value return value
...@@ -66,7 +66,6 @@ class _ErrorFormatter(object): ...@@ -66,7 +66,6 @@ class _ErrorFormatter(object):
return cls(WinError, FormatMessage, errorTab) return cls(WinError, FormatMessage, errorTab)
fromEnvironment = classmethod(fromEnvironment) fromEnvironment = classmethod(fromEnvironment)
def formatError(self, errorcode): def formatError(self, errorcode):
""" """
Returns the string associated with a Windows error message, such as the Returns the string associated with a Windows error message, such as the
......
...@@ -120,7 +120,7 @@ class WSGIHandler(object): ...@@ -120,7 +120,7 @@ class WSGIHandler(object):
except Exception: except Exception:
pass pass
# do not call self.end so that core.http replies with 500 # do not call self.end so that core.http replies with 500
self = None self = None
return return
finally: finally:
sys.exc_clear() sys.exc_clear()
......
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