issue #106: add Service.__repr__, reply to bad calls

* Don't hang callers that fail validate_args(), instead tell them their
  message was rejected.
* Add Service.repr for nicer logging.
pull/193/head
David Wilson 6 years ago
parent 8f175bf7a8
commit f6d436783c

@ -82,6 +82,12 @@ class Service(object):
self.handle = self.recv.handle
self.running = True
def __repr__(self):
return '%s.%s()' % (
self.__class__.__module__,
self.__class__.__name__,
)
def validate_args(self, args):
return (
isinstance(args, dict) and
@ -108,6 +114,7 @@ class Service(object):
isinstance(args, mitogen.core.CallError) or
not self.validate_args(args)):
LOG.warning('Received junk message: %r', args)
msg.reply(mitogen.core.CallError('Received junk message'))
return
try:

Loading…
Cancel
Save