training_node.connector#

Connector module for the DQNServer to receive messages from Redis while training.

When training a DQN model, the DQNServer alternates between training and receiving new samples from the Redis server. To interleave these two tasks, the DQNServerConnector acts as a bridge between the DQNServer and the Redis server. It asynchronously consumes messages from the Redis server and puts them into an internal queue. The messages can then be retrieved from the queue using the msgs method.

After a training step, the DQNServer does not have to wait for new samples to download from Redis, but fetches them from the internal queue instead, which should be much faster.

class soulsai.distributed.server.training_node.connector.DQNServerConnector(redis_address: str, redis_password: str)#

Connector to asynchronously receive messages from Redis.

The connector continuously polls Redis for new samples. Once a sample is available, it is put into an internal queue. The messages can then be retrieved from the queue using the msgs method.

msgs(timeout: float | None = None) list[bytes]#

Get messages from the connector.

Parameters:

timeout – The maximum time to wait for messages. If None, the method will wait indefinitely until messages are available.

Returns:

A list of messages from the connector. If no messages are available, an empty list is returned.

stop()#

Stop the connector.