cortex.core.executor¶
executor ¶
Executor for managing async functions at constant rates.
Provides utilities for executing async callbacks with precise timing, faithful to Python's cooperative multitasking model.
Classes¶
BaseExecutor ¶
Bases: ABC
Abstract base class for async executors.
Provides common interface for starting, stopping, and running async callback functions.
Source code in src/cortex/core/executor.py
AsyncExecutor ¶
Bases: BaseExecutor
Runs an async callable in a tight loop, yielding to the event loop.
Used by :class:cortex.core.subscriber.Subscriber to drive its
receive → decode → dispatch loop. Exceptions are logged and the loop
continues; only :class:asyncio.CancelledError stops it.
Example
Source code in src/cortex/core/executor.py
RateExecutor ¶
Bases: BaseExecutor
Runs an async callable at a target rate in Hz.
Uses time.perf_counter for scheduling. If a callback overruns the
nominal period, next_exec_time stays on the fixed grid (only
+ interval per invocation); the loop then sleeps 0 until the clock
catches up, so missed ticks are not skipped. This matches the
historical neurosim ZMQNODE constant-rate executor behavior and is
appropriate for simulation stepping.