Commit 8be65f8b authored by Joe Jevnik's avatar Joe Jevnik Committed by Joe Jevnik

DEV: Fixes the reprs of baseserver which were recursive when handle was

an instancemethod of the baseserver.
parent 72119c8c
......@@ -3,7 +3,7 @@
import sys
import _socket
import errno
from gevent.greenlet import Greenlet, getfuncname
from gevent.greenlet import Greenlet
from gevent.event import Event
from gevent.hub import string_types, integer_types, get_hub, xrange
......@@ -198,12 +198,25 @@ class BaseServer(object):
result += 'address=%s' % (self.address, )
except Exception as ex:
result += str(ex) or '<error>'
handle = self.__dict__.get('handle')
try:
handle = getfuncname(self.__dict__['handle'])
except Exception:
handle = None
if handle is not None:
result += ' handle=' + handle
if handle is not None:
fself = getattr(handle, '__self__')
if fself is self:
# Checks the __self__ of the handle in case it is a bound
# method of self to prevent recursivly defined reprs.
handle_repr = '<bound method %s.%s of self>' % (
self.__class__.__name__,
handle.__name__,
)
else:
handle_repr = repr(handle)
result += ' handle=' + handle_repr
except AttributeError:
pass
return result
@property
......
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