Fix EventHandler subscriptions being registered several times

This commit is contained in:
Kristóf Tóth 2018-01-31 15:10:05 +01:00
parent 1b49386da6
commit 23cc381495
3 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,4 @@
import sys import sys
import tornado import tornado
import zmq import zmq
from tornado.web import Application from tornado.web import Application

View File

@ -2,9 +2,10 @@ from transitions import Machine
class FSMBase: class FSMBase:
states, transitions, message_handlers = [], [], [] states, transitions = [], []
def __init__(self, initial: str = None): def __init__(self, initial: str = None):
self.message_handlers = []
self.machine = Machine(model=self, self.machine = Machine(model=self,
states=self.states, states=self.states,
transitions=self.transitions, transitions=self.transitions,

View File

@ -8,9 +8,11 @@ log = logging.getLogger(__name__)
class ZMQWebSocketHandler(WebSocketHandler): class ZMQWebSocketHandler(WebSocketHandler):
_event_handler_connector = EventHandlerConnector() #<--------------------. TODO: how is __init__() _event_handler_connector = EventHandlerConnector() #----.
# fix: made it static | TODO: called more than once? # TODO: investigate thread safety! <-----------------'
def __init__(self, application, request, **kwargs): #---------------------' # ZMQ sockets shared between several WebSocketHandler instances
# http://pyzmq.readthedocs.io/en/latest/morethanbindings.html#thread-safety
def __init__(self, application, request, **kwargs):
super().__init__(application, request, **kwargs) super().__init__(application, request, **kwargs)
def open(self, *args, **kwargs): def open(self, *args, **kwargs):