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

Undocumented

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 Configure bytecode-writing flags based on the current environment.
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 Undocumented
Class Variable description Undocumented
Class Variable signature Undocumented
Class Variable timestamps Undocumented
Instance Variable __call_in_shutdown Undocumented
Instance Variable __cmd Undocumented
Instance Variable __env Undocumented
Instance Variable __lock Undocumented
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: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
NoneThis method does not return a value.
def __appendLoggingConfigurationToCommand(self, app: IApplication): (source)

Append the logging-level flags to the command.

Parameters
app: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
NoneThis method does not return a value.
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: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:IApplicationThe running application instance.
Returns
NoneThis method does not return a value.
def __appendWorkersToCommand(self): (source)

Append the worker-process count to the command.

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

Configure bytecode-writing flags based on the current environment.

Parameters
app:IApplicationThe running application instance.
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

Used on Windows when a debugger is attached. Workers run as asyncio tasks so debugpy breakpoints work without subprocess interception issues.

Lifecycle is managed explicitly because Application.__rsgi_init__ calls loop.run_until_complete(), which raises RuntimeError when the loop is already running, and asyncio.ensure_future(loop=) was removed in Python 3.12+.

Parameters
app:IApplicationThe running application instance.
Returns
NoneThis method does not return a value.
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: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 without changing environment variables 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

Dispatches to the appropriate server strategy:

  • Unix: replaces the process via execvpe.
  • Windows + debugger: uses the Granian embedded server (in-process asyncio tasks) for full breakpoint support.
  • Windows: launches Granian as a managed subprocess.
Parameters
app:IApplicationThe running application instance.
Returns
NoneThis method does not return a value.
arguments: ClassVar[list[Argument]] = (source)

Undocumented

description: str = (source)

Undocumented

signature: str = (source)

Undocumented

timestamps: bool = (source)

Undocumented

__call_in_shutdown: Callable | None = (source)

Undocumented

Undocumented

Undocumented

Undocumented