From f6d436783c401fb9a54b56a8471c12f02283ba0c Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 1 Apr 2018 11:28:42 +0100 Subject: [PATCH] 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. --- mitogen/service.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mitogen/service.py b/mitogen/service.py index b9fad1fe..018fa17d 100644 --- a/mitogen/service.py +++ b/mitogen/service.py @@ -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: