vantage6.node.socket.NodeTaskNamespace#

class NodeTaskNamespace(*args, **kwargs)#

Bases: ClientNamespace

Class that handles incoming websocket events.

__init__(*args, **kwargs)#

Handler for a websocket namespace.

Methods

__init__(*args, **kwargs)

Handler for a websocket namespace.

call(event[, data, namespace, timeout])

Emit a custom event to the server and wait for the response.

disconnect()

Disconnect from the server.

emit(event[, data, namespace, callback])

Emit a custom event to the server.

is_asyncio_based()

on_algorithm_status_change(data)

Actions to be taken when an algorithm container in the collaboration has changed its status.

on_connect()

Alert the node that the websocket connection has been established.

on_disconnect()

Actions to be taken on socket disconnect event.

on_expired_token()

Action to be taken when node is notified by server that its token has expired.

on_invalid_token()

The server indicates that this node has an invalid token.

on_kill_containers(kill_info)

Action to be taken when nodes are instructed by server to kill one or more tasks

on_message(msg)

Receive messages over socket connection

on_new_task(data)

Actions to be taken when node is notified of new task by server

on_sync()

Actions to be taken on socket sync event.

send(data[, room, namespace, callback])

Send a message to the server.

trigger_event(event, *args)

Dispatch an event to the proper handler method.

Attributes

node_worker_ref

call(event, data=None, namespace=None, timeout=None)#

Emit a custom event to the server and wait for the response.

The only difference with the socketio.Client.call() method is that when the namespace argument is not given the namespace associated with the class is used.

disconnect()#

Disconnect from the server.

The only difference with the socketio.Client.disconnect() method is that when the namespace argument is not given the namespace associated with the class is used.

emit(event, data=None, namespace=None, callback=None)#

Emit a custom event to the server.

The only difference with the socketio.Client.emit() method is that when the namespace argument is not given the namespace associated with the class is used.

on_algorithm_status_change(data)#

Actions to be taken when an algorithm container in the collaboration has changed its status.

Parameters:

data (dict) –

Dictionary with relevant data to the status change. Should include: job_id: int

job_id of the algorithm container that changed status

status: str

New status of the algorithm container

on_connect()#

Alert the node that the websocket connection has been established.

on_disconnect()#

Actions to be taken on socket disconnect event.

on_expired_token()#

Action to be taken when node is notified by server that its token has expired.

on_invalid_token()#

The server indicates that this node has an invalid token. We should reauthenticate.

Return type:

None

on_kill_containers(kill_info)#

Action to be taken when nodes are instructed by server to kill one or more tasks

Parameters:

kill_info (dict) – A dictionary that contains information on which tasks should be killed. This information may instruct a node to kill all its tasks or include a list of which tasks should be killed.

on_message(msg)#

Receive messages over socket connection

Parameters:

msg (any) – A message that will be printed to the node logs. Usually a str.

on_new_task(data)#

Actions to be taken when node is notified of new task by server

Parameters:

data (dict) –

Dictionary with relevant data to the new task. Should include: id: int

ID of the new task

parent_id: int | None

ID of the parent task (if any)

on_sync()#

Actions to be taken on socket sync event. This event is triggered by the server when the node connects to the socket namespace.

send(data, room=None, namespace=None, callback=None)#

Send a message to the server.

The only difference with the socketio.Client.send() method is that when the namespace argument is not given the namespace associated with the class is used.

trigger_event(event, *args)#

Dispatch an event to the proper handler method.

In the most common usage, this method is not overloaded by subclasses, as it performs the routing of events to methods. However, this method can be overridden if special dispatching rules are needed, or if having a single method that catches all events is desired.