Skip to content

Commit

Permalink
Reorder comms super() call so process is set first
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed Sep 20, 2016
1 parent cc84fc7 commit ea81829
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion malcolm/comms/pva/pvaclientcomms.py
Expand Up @@ -16,9 +16,9 @@ def __init__(self, process, _=None):
name (str): Name for logging
process (Process): Process for primitive creation
"""
super(PvaClientComms, self).__init__(process)
self.name = "PvaClientComms"
self.set_logger_name(self.name)
super(PvaClientComms, self).__init__(process)

def send_to_server(self, request):
"""Dispatch a request to the server
Expand Down
4 changes: 2 additions & 2 deletions malcolm/comms/pva/pvaservercomms.py
Expand Up @@ -19,6 +19,8 @@ class PvaServerComms(ServerComms, PvaUtil):
CACHE_UPDATE = 0

def __init__(self, process, _=None):
super(PvaServerComms, self).__init__(process)

self.name = "PvaServerComms"
self.set_logger_name(self.name)

Expand All @@ -43,8 +45,6 @@ def __init__(self, process, _=None):
# Add a thread for executing the V4 PVA server
self.add_spawn_function(self.start_pva_server)

super(PvaServerComms, self).__init__(process)

# Set up the subscription for everything (root down)
request = Subscribe(None, self.q, [], True)
request.set_id(self._root_id)
Expand Down
2 changes: 1 addition & 1 deletion malcolm/comms/websocket/websocketclientcomms.py
Expand Up @@ -21,6 +21,7 @@ def __init__(self, process, params):
process (Process): Process for primitive creation
params (Map): Parameters map
"""
super(WebsocketClientComms, self).__init__(process)
self.url = "ws://%(hostname)s:%(port)d/ws" % params
self.set_logger_name(self.url)
# TODO: Are we starting one or more IOLoops here?
Expand All @@ -29,7 +30,6 @@ def __init__(self, process, params):
self.url, callback=self.subscribe_server_blocks,
on_message_callback=self.on_message)
self.add_spawn_function(self.loop.start, self.stop_recv_loop)
super(WebsocketClientComms, self).__init__(process)

def on_message(self, message):
"""
Expand Down
2 changes: 1 addition & 1 deletion malcolm/comms/websocket/websocketservercomms.py
Expand Up @@ -55,6 +55,7 @@ class WebsocketServerComms(ServerComms):
"""A class for communication between browser and server"""

def __init__(self, process, params):
super(WebsocketServerComms, self).__init__(process)
self.set_logger_name("WebsocketServerComms(%(port)d)" % params)
MalcWebSocketHandler.servercomms = self
MalcBlockHandler.servercomms = self
Expand All @@ -67,7 +68,6 @@ def __init__(self, process, params):
self.server.listen(int(params["port"]))
self.loop = IOLoop.current()
self.add_spawn_function(self.loop.start, self.stop_recv_loop)
super(WebsocketServerComms, self).__init__(process)

def send_to_client(self, response):
"""Dispatch response to a client
Expand Down
Expand Up @@ -104,7 +104,7 @@ def test_start(self, ioloop_mock, _):
self.WS.process.spawn = MagicMock()
self.WS.start()

self.assertEqual([call(self.WS.loop.start), call(self.WS.send_loop)],
self.assertEqual([call(self.WS.send_loop), call(self.WS.loop.start)],
self.WS.process.spawn.call_args_list)

@patch('malcolm.comms.websocket.websocketclientcomms.websocket_connect')
Expand Down
Expand Up @@ -44,7 +44,7 @@ def test_start(self, _, _2):
self.WS = WebsocketServerComms(self.p, dict(port=1))
self.WS.start()

self.assertEqual([call(self.WS.loop.start), call(self.WS.send_loop)],
self.assertEqual([call(self.WS.send_loop), call(self.WS.loop.start)],
self.p.spawn.call_args_list)

@patch('malcolm.comms.websocket.websocketservercomms.HTTPServer')
Expand Down

0 comments on commit ea81829

Please sign in to comment.