proxystore.stream.shims.queue¶
Python queue-based pub/sub implementation.
Warning
This implementation is meant for streaming between Python threads within the same process, or between Python processes on the same machine. Each queue topic may only have one subscriber.
QueuePublisher
¶
QueuePublisher(
queues: Mapping[str, Queue[bytes] | Queue[bytes]],
*,
block: bool = True,
timeout: float | None = None
)
Publisher built on Python queues.
Warning
Each topic can only have one subscriber.
Parameters:
-
queues(Mapping[str, Queue[bytes] | Queue[bytes]]) –Mapping of topic name to Python queue.
-
block(bool, default:True) –Block until a free slot is available when sending a new message to the queue.
-
timeout(float | None, default:None) –Block at most
timeoutseconds.
Source code in proxystore/stream/shims/queue.py
close
¶
send_message
¶
Publish a message to the stream.
Parameters:
-
topic(str) –Stream topic to publish message to.
-
message(bytes) –Message as bytes to publish to the stream.
Raises:
-
ValueError–if a queue with the name
topicdoes not exist.
Source code in proxystore/stream/shims/queue.py
QueueSubscriber
¶
QueueSubscriber(
queue: Queue[bytes] | Queue[bytes],
*,
block: bool = True,
timeout: float | None = None
)
Subscriber to a QueuePublisher topic.
Warning
Each topic can only have one subscriber.
Parameters:
-
queue(Queue[bytes] | Queue[bytes]) –Queue shared with the
QueuePublisherto pull messages from. -
block(bool, default:True) –Block until the next message is available in the queue.
-
timeout(float | None, default:None) –Block at most
timeoutseconds.