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 tornado
import zmq
from tornado.web import Application

View File

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

View File

@ -8,9 +8,11 @@ log = logging.getLogger(__name__)
class ZMQWebSocketHandler(WebSocketHandler):
_event_handler_connector = EventHandlerConnector() #<--------------------. TODO: how is __init__()
# fix: made it static | TODO: called more than once?
def __init__(self, application, request, **kwargs): #---------------------'
_event_handler_connector = EventHandlerConnector() #----.
# TODO: investigate thread safety! <-----------------'
# 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)
def open(self, *args, **kwargs):