improv.link
#
Module Contents#
Classes#
Single-output and asynchronous queue class. |
|
Extension of AsyncQueue to have multiple endpoints. |
Functions#
|
Function to construct a queue that Nexus uses for |
|
Function to generate links for the multi-output queue case. |
Attributes#
- improv.link.logger#
- improv.link.Link(name, start, end)[source]#
Function to construct a queue that Nexus uses for inter-process (actor) signaling and information passing.
A Link has an internal queue that can be synchronous (put, get) as inherited from multiprocessing.Manager.Queue or asynchronous (put_async, get_async) using async executors.
- Parameters:
constructor (See AsyncQueue) –
- Returns:
queue for communicating between actors and with Nexus
- Return type:
- class improv.link.AsyncQueue(q, name, start, end)[source]#
Bases:
object
Single-output and asynchronous queue class.
- queue#
- real_executor#
- cancelled_join#
boolean
- name#
- start#
- end#
- status#
- result#
- num#
- dict#
- getStart()[source]#
Gets the starting actor.
The starting actor is the actor that is at the tail of the link. This actor is the one that gives output.
- Returns:
The starting actor name
- Return type:
start (str)
- getEnd()[source]#
Gets the ending actor.
The ending actor is the actor that is at the head of the link. This actor is the one that takes input.
- Returns:
The ending actor name
- Return type:
end (str)
- put(item)[source]#
Function wrapper for put.
- Parameters:
item (object) – Any item that can be sent through a queue
- put_nowait(item)[source]#
Function wrapper for put without waiting
- Parameters:
item (object) – Any item that can be sent through a queue
- async put_async(item)[source]#
Coroutine for an asynchronous put
It adds the put request to the event loop and awaits.
- Parameters:
item (object) – Any item that can be sent through a queue
- Returns:
Awaitable or result of the put
- async get_async()[source]#
Coroutine for an asynchronous get
It adds the get request to the event loop and awaits, setting the status to pending. Once the get has returned, it returns the result of the get and sets its status as done.
Explicitly passes any exceptions to not hinder execution. Errors are logged with the get_async tag.
- Returns:
Awaitable or result of the get.
- Raises:
CancelledError – task is cancelled
EOFError –
FileNotFoundError –
Exception –
- improv.link.MultiLink(name, start, end)[source]#
Function to generate links for the multi-output queue case.
- Parameters:
MultiAsyncQueue (See constructor for AsyncQueue or) –
- Returns:
Producer end of the queue List: AsyncQueues for consumers
- Return type:
- class improv.link.MultiAsyncQueue(q_in, q_out, name, start, end)[source]#
Bases:
AsyncQueue
Extension of AsyncQueue to have multiple endpoints.
Inherits from AsyncQueue. A single producer queue’s ‘put’ is copied to multiple consumer’s queues, q_in is the producer queue, q_out are the consumer queues.