app
Tokamak §
Tokamak(router=None, background_task_time_limit=None, background_task_limit=1000, request_time_limit=None, cancelled_request_handler=errors.default_cancelled_request_handler, lifespan=lifespan_identity)
When using the Tokamak App instance, you should define handlers
that take a tokamak.web.request.Request
instance.
tokamak.web.request.Request
uses in-memory-channels to:
- send back a Response, and
- to schedule background work.
This design aids in building in cancellation primitives (via Trio) into this library.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
router |
Optional[`tokamak.router.AsgiRouter`]
|
A router instance. str)`. |
None
|
background_task_time_limit |
Optional[int]
|
Runtime Limit (in seconds) for background tasks. |
None
|
background_task_limit |
int
|
Total limit of schedulable background tasks (backpressure will apply) |
1000
|
request_time_limit |
Optional[int]
|
Runtime Limit (in seconds) for request handlers. |
None
|
cancelled_request_handler |
Optional[Callable]
|
Handler for cancelled requests |
errors.default_cancelled_request_handler
|
lifespan |
Callable
|
An async function with signature: `async def lifespan(tok: Tokamak, message_type: |
lifespan_identity
|
lifespan_identity
async
§
lifespan_identity(app, message_type='')
A default implementation of lifespan: the identity function