jvconnected.interfaces.midi.aioport
- class jvconnected.interfaces.midi.aioport.BasePort(*args, **kwargs)[source]
Bases:
DispatcherAsync wrapper for
mido.ports- Parameters
name (str) – The port name
- stopped
- Type
- Property running: bool = False
Current run state
runningis apydispatch.Propertyobject.
- EXECUTOR: ClassVar[concurrent.futures.ThreadPoolExecutor] = None
A
concurrent.futures.ThreadPoolExecutorto use in therun_in_executor()method for all instances of allBasePortsubclasses
- Property name: str = None
The port name
nameis apydispatch.Propertyobject.
- static get_executor() concurrent.futures.ThreadPoolExecutor[source]
Get or create the
EXECUTORinstance to use in therun_in_executor()method
- async run_in_executor(fn: Callable) Any[source]
Call the given function in the
EXECUTORinstance usingasyncio.loop.run_in_executor()and return the resultThis method is used to create and manipulate all
midoports to avoid blocking, threaded operations
- class jvconnected.interfaces.midi.aioport.InputPort(*args, **kwargs)[source]
Bases:
BasePortAsync wrapper around
mido.ports.BaseInput- queue
Message queue for the port
- Type
- async receive(timeout: Optional[Number] = None) Optional[Message][source]
Wait for an incoming message
- Parameters
timeout (float, optional) – Time to wait for a message. if
None, wait until an item is available- Returns
An instance of
mido.Message. If timeout was provided and no message was retrieved,Nonewill be returned.- Return type
Optional[Message]
- async receive_many(block: bool = True, timeout: Optional[Number] = None) Optional[Union[bool, Tuple[Message]]][source]
Gather any/all available messages
- Parameters
block (bool, optional) – If
True,wait_for_msg()is used initially to wait for the first available message. IfFalse, only check for queued messages and return immediately if none exist. Default isTruetimeout (float, optional) – If block is
Truethe timeout argument to pass to thewait_for_msg()method
- Returns
If no messages were available (either block was
Falseor the timeout was reached),Noneis returned.- Return type
- async wait_for_msg(timeout: Optional[Number] = None) bool[source]
Wait until a message is available
- async queue_get(timeout: Optional[Number] = None) Any[source]
Convenience method for
get()on thequeue- Parameters
timeout (float, optional) – Time to wait for an item on the queue. if
None, wait until an item is available
- async queue_iter_get() AsyncGenerator[Message, None][source]
Iterate over any/all messages available on the queue
- task_done()[source]
Convenience method for
queuetask_done()
- class jvconnected.interfaces.midi.aioport.OutputPort(*args, **kwargs)[source]
Bases:
BasePortAsync wrapper around
mido.ports.BaseOutput- queue
Message queue for the port. Since the output port operates in a separate thread, this is a thread-based queue (not async)
- Type
- async open() bool[source]
Open the midi port
- Returns
Trueif the port was successfully opened- Return type
- async send(msg: Message)[source]
Send a message
The message will be placed on the
queueand sent from a separate thread- Parameters
msg (Message) – The
mido.Messageto send