labthings_fastapi.dependencies.blocking_portal

FastAPI dependency for a blocking portal

This allows dependencies that are called by threaded code to send things back to the async event loop.

Module Contents

Functions

blocking_portal_from_thing_server

Return the blocking portal from our ThingServer

Data

BlockingPortal

A ready-made dependency type for a blocking portal. If you use an argument with type BlockingPortal, FastAPI will automatically inject the blocking portal. This is simply shorthand for anyio.from_thread.BlockingPortal annotated with Depends(blocking_portal_from_thing_server).

API

labthings_fastapi.dependencies.blocking_portal.blocking_portal_from_thing_server(request: fastapi.Request) anyio.from_thread.BlockingPortal

Return the blocking portal from our ThingServer

This is for use as a FastAPI dependency, to allow threaded code to call async code.

labthings_fastapi.dependencies.blocking_portal.BlockingPortal

None

A ready-made dependency type for a blocking portal. If you use an argument with type BlockingPortal, FastAPI will automatically inject the blocking portal. This is simply shorthand for anyio.from_thread.BlockingPortal annotated with Depends(blocking_portal_from_thing_server).