mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 22:51:32 +00:00
Fix EventHandler subscriptions being registered several times
This commit is contained in:
parent
1b49386da6
commit
23cc381495
@ -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
|
||||||
|
@ -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,
|
||||||
|
@ -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):
|
||||||
|
Loading…
Reference in New Issue
Block a user