From 26ef7305694142327826a4391984799007774219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Bokros?= Date: Tue, 5 Dec 2017 17:51:34 +0100 Subject: [PATCH] Make StatefulEventHandler's code clearer --- src/event_handlers/stateful_event_handler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/event_handlers/stateful_event_handler.py b/src/event_handlers/stateful_event_handler.py index 0b9f6bd..520d958 100644 --- a/src/event_handlers/stateful_event_handler.py +++ b/src/event_handlers/stateful_event_handler.py @@ -13,7 +13,7 @@ class StatefulEventHandler(EventHandlerBase): self.generator = None self.subscribe('reset') - def wrapper(msg_parts, handler): + def event_handler_callback(msg_parts): anchor, message = msg_parts if anchor == b'reset': self.generator = None @@ -23,7 +23,7 @@ class StatefulEventHandler(EventHandlerBase): return data_json = json.loads(message) if self.generator is None: - self.generator = handler(data_json, self) + self.generator = self.event_handler_function(data_json, self) response_anchor, response_data = next(self.generator) if response_anchor is None: return @@ -37,4 +37,4 @@ class StatefulEventHandler(EventHandlerBase): response = [r.encode('utf-8') for r in (response_anchor, response_data)] self.zmq_push_socket.send_multipart(response) - self.zmq_sub_stream.on_recv(partial(wrapper, handler=event_handler_function)) + self.zmq_sub_stream.on_recv(event_handler_callback)