MCPcopy
hub / github.com/benoitc/gunicorn / get_dirty_client_async

Function get_dirty_client_async

gunicorn/dirty/client.py:710–737  ·  view source on GitHub ↗

Get or create a context-local async client. This is the recommended way to get a client in async HTTP workers. Args: timeout: Timeout for operations in seconds Returns: DirtyClient: Context-local client instance Example:: from gunicorn.dirty import g

(timeout=30.0)

Source from the content-addressed store, hash-verified

708
709
710async def get_dirty_client_async(timeout=30.0) -> DirtyClient:
711 """
712 Get or create a context-local async client.
713
714 This is the recommended way to get a client in async HTTP workers.
715
716 Args:
717 timeout: Timeout for operations in seconds
718
719 Returns:
720 DirtyClient: Context-local client instance
721
722 Example::
723
724 from gunicorn.dirty import get_dirty_client_async
725
726 async def my_view(request):
727 client = await get_dirty_client_async()
728 result = await client.execute_async("myapp.ml:MLApp", "inference", data)
729 return result
730 """
731 try:
732 client = _async_client_var.get()
733 except LookupError:
734 socket_path = get_dirty_socket_path()
735 client = DirtyClient(socket_path, timeout=timeout)
736 _async_client_var.set(client)
737 return client
738
739
740def close_dirty_client():

Callers 15

chatFunction · 0.90
chat_syncFunction · 0.90
send_emailFunction · 0.90
generateFunction · 0.90
email_statsFunction · 0.90
resize_imageFunction · 0.90
generate_thumbnailFunction · 0.90
image_statsFunction · 0.90
aggregate_dataFunction · 0.90
cached_queryFunction · 0.90
data_statsFunction · 0.90
run_cleanupFunction · 0.90

Calls 4

get_dirty_socket_pathFunction · 0.85
DirtyClientClass · 0.85
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected