ORIONIS API REFERENCE

THE ORIONIS API

Build with clarity.

Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.

class documentation

class ServerCommand(BaseCommand): (source)

Constructor: ServerCommand()

View In Hierarchy

Start the application server using the selected runtime options.

Static Method __isDebugMode Detect whether a Python debugger is currently attached.
Method __appendHostAndPortToCommand Resolve and append host and port arguments to the command.
Method __appendInterfaceToCommand Append the selected interface type to the command.
Method __appendLoggingConfigurationToCommand Append the logging-level flags to the command.
Method __appendLoopToCommand Append the event-loop backend to the command.
Method __appendProcessNameToCommand Append the process name to the command.
Method __appendReloadOptionsToCommand Append hot-reload flags and watched directories to the command.
Method __appendStaticMountAndRouteToCommand Append the static-file mount path and URL route to the command.
Method __appendWorkersToCommand Append the worker-process count to the command.
Method __configureBytecodeWriting Disable bytecode writes in this interpreter and all server processes.
Async Method __embeddedServe Start the server in-process using Granian's embedded backend.
Method __init__ Initialize command arguments and server launch state.
Method __initNewEnvironment Build a fresh environment dictionary with Orionis metadata.
Method __setShutdownHandler Assign the application shutdown coroutine for later invocation.
Method __unixServe Replace the current process with the Granian server via execvpe.
Async Method __windowsServe Launch Granian as a managed subprocess on Windows.
Async Method handle Build the Granian command and start the HTTP server.
Class Variable arguments Command-line argument declarations accepted by this command.
Class Variable description Initializes the Orionis server with Granian (The Rust HTTP server for Python)..
Class Variable signature Command signature and description.
Class Variable timestamps Timestamps flag used by ServerCommand.
Instance Variable __call_in_shutdown Callbacks invoked when the server shuts down.
Instance Variable __cmd Argument vector used to launch the application server.
Instance Variable __env Environment overrides passed to the application server process.
Instance Variable __lock Lock protecting concurrent access to shared state.
def __isDebugMode() -> bool: (source)

Detect whether a Python debugger is currently attached.

Notes

Covers legacy trace-based debuggers (sys.gettrace) and debugpy >= 1.8 on Python >= 3.12, which uses sys.monitoring and no longer sets a global trace function but always imports pydevd during its bootstrap.

Returns
boolTrue if a debugger is attached, False otherwise.
def __appendHostAndPortToCommand(self, app: IApplication): (source)

Resolve and append host and port arguments to the command.

Parameters
app:orionis.IApplicationThe running application instance.
Returns
NoneThis method does not return a value.
def __appendInterfaceToCommand(self): (source)

Append the selected interface type to the command.

Returns
NoneAppend flags and record the selected interface.
def __appendLoggingConfigurationToCommand(self, app: IApplication): (source)

Append the logging-level flags to the command.

Parameters
app:orionis.IApplicationThe running application instance.
Returns
NoneThis method does not return a value.
def __appendLoopToCommand(self): (source)

Append the event-loop backend to the command.

Returns
NoneAppend the loop flag and record its selection.
def __appendProcessNameToCommand(self, name: str): (source)

Append the process name to the command.

Parameters
name:strIdentifier shown in the OS process list.
Returns
NoneThis method does not return a value.
def __appendReloadOptionsToCommand(self, app: IApplication): (source)

Append hot-reload flags and watched directories to the command.

Parameters
app:orionis.IApplicationThe running application instance.
Returns
NoneThis method does not return a value.
def __appendStaticMountAndRouteToCommand(self, app: IApplication): (source)

Append the static-file mount path and URL route to the command.

Parameters
app:orionis.IApplicationThe running application instance.
Returns
NoneThis method does not return a value.
def __appendWorkersToCommand(self): (source)

Append the worker-process count to the command.

Returns
NoneThis method does not return a value.
def __configureBytecodeWriting(self): (source)

Disable bytecode writes in this interpreter and all server processes.

Returns
NoneThis method does not return a value.
async def __embeddedServe(self, app: IApplication): (source)

Start the server in-process using Granian's embedded backend.

Notes

Windows debugger sessions use asyncio tasks. Drive RSGI startup and shutdown explicitly because the application's synchronous RSGI hooks cannot run inside an active event loop.

Parameters
app:orionis.IApplicationThe running application instance.
Returns
NoneComplete the embedded server lifecycle.
def __init__(self): (source)

Initialize command arguments and server launch state.

Returns
NoneThis method does not return a value.
def __initNewEnvironment(self) -> dict[str, str]: (source)

Build a fresh environment dictionary with Orionis metadata.

Returns
dict[str, str]A copy of os.environ extended with framework-specific keys.
def __setShutdownHandler(self, app: IApplication): (source)

Assign the application shutdown coroutine for later invocation.

Parameters
app:orionis.IApplicationThe running application instance.
Returns
NoneThis method does not return a value.
def __unixServe(self): (source)

Replace the current process with the Granian server via execvpe.

Returns
NoneThis method never returns; the process is replaced by execvpe.
async def __windowsServe(self): (source)

Launch Granian as a managed subprocess on Windows.

Notes

Passes the copied environment to the subprocess. Server-specific settings remain isolated; bytecode protection is also enforced in the parent process.

Uses asyncio.create_subprocess_exec so that await proc.wait() is directly cancellable by the event loop. On CancelledError (Ctrl+C), taskkill /F /T terminates the entire process tree (main Granian process and all worker children) before the shutdown handler is called.

Returns
NoneThis method does not return a value.
async def handle(self, app: IApplication): (source)

Build the Granian command and start the HTTP server.

Notes

Replace the process on Unix. On Windows, use the embedded server for debugger sessions and a managed subprocess otherwise.

Parameters
app:orionis.IApplicationThe running application instance.
Returns
NoneLaunch the selected runtime or report an exported command.
arguments: ClassVar[list[Argument]] = (source)

Command-line argument declarations accepted by this command.

description: str = (source)

Initializes the Orionis server with Granian (The Rust HTTP server for Python)..

signature: str = (source)

Command signature and description.

timestamps: bool = (source)

Timestamps flag used by ServerCommand.

__call_in_shutdown: Callable | None = (source)

Callbacks invoked when the server shuts down.

Argument vector used to launch the application server.

Environment overrides passed to the application server process.

Lock protecting concurrent access to shared state.