ReplayWriter
python
ReplayWriter(replay_buffer: ReplayBuffer, stop_event: Event, max_queue_size: int) -> NoneDedicated replay-buffer insertion stage for DQN.
Actor threads enqueue owned replay batches here; the replay writer serializes replay_buffer.add(...) calls onto a single thread to keep replay insertion off the actor hot path.
Initialize the replay writer.
Parameters:
replay_buffer(ReplayBuffer) – Replay buffer receiving inserted transitions.stop_event(Event) – Shared experiment stop event.max_queue_size(int) – Maximum number of replay batches that may be queued.
Properties
queue_depth
python
queue_depth: intGet the current replay queue depth.
Returns:
int– The number of queued replay batches.
replay_buffer
python
replay_buffer: ReplayBufferGet the replay buffer currently owned by the writer.
Returns:
ReplayBuffer– The replay buffer.
Methods
drain
python
drain() -> NoneWait for all queued replay work to be inserted.
enqueue
python
enqueue(batch: ReplayBatch) -> NoneEnqueue a replay batch for insertion.
Blocks when the bounded queue is full.
Parameters:
batch(ReplayBatch) – Replay batch to insert.
replace_replay_buffer
python
replace_replay_buffer(replay_buffer: ReplayBuffer) -> NoneReplace the replay buffer target.
Parameters:
replay_buffer(ReplayBuffer) – The new replay buffer.
run
python
run() -> NoneProcess queued replay batches until stop is requested and the queue is drained.