flowno.core.event_loop.commands

Internal Command Types for the Flowno Event Loop

This module defines the command types used by the Flowno event loop to implement its cooperative multitasking system. Commands are yielded by coroutines and interpreted by the event loop to perform operations like task scheduling, I/O operations, and synchronization.

Warning

These command types are used internally by the Flowno event loop to control task scheduling, socket operations, and asynchronous queue interactions. They are not part of the public API. Normal users should rely on the public awaitable primitives (e.g. sleep(), spawn(), etc.) rather than yielding these commands directly.

class flowno.core.event_loop.commands.Command[source]

Base abstract class for all internal command types.

Note

These commands are part of the Flowno event loop’s internal control mechanism. Application developers should not use or yield these commands directly.

class flowno.core.event_loop.commands.JoinCommand(task_handle: TaskHandle[_T])[source]

Internal command to suspend a task until another task finishes.

Parameters:

task_handle – A handle to the task to join.

Note

This is used internally to implement the TaskHandle.join() awaitable.

class flowno.core.event_loop.commands.QueueCloseCommand(queue: AsyncQueue[_T])[source]

Internal command to close an asynchronous queue.

Parameters:

queue – The asynchronous queue to be closed.

Note

This command is used internally by the event loop when closing queues.

class flowno.core.event_loop.commands.QueueGetCommand(queue: AsyncQueue[_T], peek: bool = False)[source]

Internal command to retrieve an item from an asynchronous queue.

Parameters:
  • queue – The asynchronous queue from which to retrieve the item.

  • peek – If True, the command will not remove the item from the queue.

Note

This command is used internally to implement the blocking get behavior.

class flowno.core.event_loop.commands.QueueNotifyGettersCommand(queue: AsyncQueue[_T])[source]

Internal command to notify tasks waiting for items on an asynchronous queue.

Parameters:

queue – The asynchronous queue whose waiting getters should be notified.

Note

This command is used internally when an item is added to a queue to wake up tasks blocked on a get operation.

class flowno.core.event_loop.commands.QueuePutCommand(queue: AsyncQueue[_T], item: _T)[source]

Internal command to put an item into an asynchronous queue.

Parameters:
  • queue – The asynchronous queue into which the item should be inserted.

  • item – The item to be inserted.

Note

This command is used internally to implement the blocking put behavior.

class flowno.core.event_loop.commands.SleepCommand(end_time: float)[source]

Internal command to suspend a task until a specified time.

Parameters:

end_time – The time (as a DeltaTime) until which the task should sleep.

Note

Users should use the public sleep() primitive rather than yielding a SleepCommand.

class flowno.core.event_loop.commands.SocketAcceptCommand(handle: SocketHandle)[source]

Internal command requesting to accept a new connection on a socket.

class flowno.core.event_loop.commands.SocketCommand(handle: SocketHandle)[source]

Base internal command for socket operations.

Parameters:

handle – The socket handle associated with this operation.

Note

These commands are used by the event loop to implement non-blocking I/O.

class flowno.core.event_loop.commands.SocketRecvCommand(handle: SocketHandle)[source]

Internal command indicating that data is to be received from a socket.

class flowno.core.event_loop.commands.SocketSendCommand(handle: SocketHandle)[source]

Internal command indicating that data is to be sent over a socket.

class flowno.core.event_loop.commands.SpawnCommand(raw_task: Coroutine[Command, Any, _T_co])[source]

Internal command to spawn a new raw task.

Parameters:

raw_task – The raw task coroutine to be scheduled.

Note

Users should use the public spawn() primitive instead of yielding a SpawnCommand directly.