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 HTTPRequestPrinter(IHTTPRequestPrinter): (source)
Constructor: HTTPRequestPrinter()
Queue and display formatted HTTP request timing information.
| Method | __init__ |
Initialize the HTTPRequestPrinter instance. |
| Async Method | __worker |
Write queued lines to stdout in the background. |
| Method | print |
Print a formatted HTTP request line to stdout or queue. |
| Method | set |
Set whether to enable or disable console output for HTTP requests. |
| Async Method | start |
Start the background print worker. |
| Method | start |
Capture the current high-resolution timestamp for request timing. |
| Async Method | stop |
Drain remaining output and stop the background worker. |
| Constant | HTTP |
(bg_ansi, fg_ansi) tuples for HTTP methods. |
| Constant | HTTP |
Minimum valid HTTP status code. |
| Constant | STATUS |
(bg_ansi, fg_ansi) tuples for HTTP status categories. |
| Instance Variable | __enabled |
Enable HTTP request printing to console by default. |
| Instance Variable | __lifecycle |
Serialize worker startup and shutdown. |
| Instance Variable | __queue |
Async queue and worker task (initialized by start()). |
| Instance Variable | __start |
Context-local timestamp set by startTimer for each request. |
| Instance Variable | __status |
Precompute status icons by HTTP code category. |
| Instance Variable | __worker |
Background task responsible for draining queued output. |
| Instance Variable | _flush |
Flush obtained from sys.stdout.flush. |
| Instance Variable | _total |
Total width produced by max. |
| Instance Variable | _write |
LOAD_FAST vs sys.stdout LOAD_GLOBAL+LOAD_ATTR. |
Initialize the HTTPRequestPrinter instance.
Determines terminal width, precomputes reusable ANSI-coloured strings, and prepares the async queue and worker task references.
| Returns | |
None | This method does not return a value. |
Write queued lines to stdout in the background.
Continuously reads lines from the internal async queue and writes them to stdout, flushing after each write to ensure immediate display.
| Parameters | |
queue:asyncio.Queue[str] | Queue owned by this worker until shutdown. |
| Returns | |
None | This method does not return a value. |
Print a formatted HTTP request line to stdout or queue.
Computes the elapsed duration from start_time, builds an ANSI-coloured output line, and either enqueues it for the background worker (if start() was called) or writes directly to stdout.
| Parameters | |
adapter:orionis.http.adapters.request.contracts.transport.TransportAdapter | The transport adapter providing method and path information. |
response:orionis.http.Response | The HTTP response object. |
| Returns | |
None | This method does not return a value. |
Start the background print worker.
Create the internal async queue and a worker, or reuse the active worker. Serialize startup with shutdown and close a rejected worker coroutine.
| Returns | |
None | This method does not return a value. |
Capture the current high-resolution timestamp for request timing.
Returns None immediately if printing is disabled, avoiding unnecessary work when output has been suppressed via setEnabled(enabled=False).
| Returns | |
float | None | A high-resolution monotonic timestamp from time.perf_counter(), or None if output is disabled. |
Drain remaining output and stop the background worker.
Close queue admission and await the worker directly, so a failed writer cannot strand shutdown behind unfinished queue items. Release references after success, failure, or cancellation. Safe before startup.
| Returns | |
None | This method does not return a value. |
| Raises | |
OSError | If the output stream fails while writing or flushing. |
asyncio.CancelledError | If shutdown or the worker is cancelled. |
(bg_ansi, fg_ansi) tuples for HTTP status categories.
| Value |
|