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.
This commit is contained in:
parent
8f175bf7a8
commit
f6d436783c
|
@ -82,6 +82,12 @@ class Service(object):
|
||||||
self.handle = self.recv.handle
|
self.handle = self.recv.handle
|
||||||
self.running = True
|
self.running = True
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '%s.%s()' % (
|
||||||
|
self.__class__.__module__,
|
||||||
|
self.__class__.__name__,
|
||||||
|
)
|
||||||
|
|
||||||
def validate_args(self, args):
|
def validate_args(self, args):
|
||||||
return (
|
return (
|
||||||
isinstance(args, dict) and
|
isinstance(args, dict) and
|
||||||
|
@ -108,6 +114,7 @@ class Service(object):
|
||||||
isinstance(args, mitogen.core.CallError) or
|
isinstance(args, mitogen.core.CallError) or
|
||||||
not self.validate_args(args)):
|
not self.validate_args(args)):
|
||||||
LOG.warning('Received junk message: %r', args)
|
LOG.warning('Received junk message: %r', args)
|
||||||
|
msg.reply(mitogen.core.CallError('Received junk message'))
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue