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

Function get_dirty_client

gunicorn/dirty/client.py:681–707  ·  view source on GitHub ↗

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

(timeout=30.0)

Source from the content-addressed store, hash-verified

679
680
681def get_dirty_client(timeout=30.0) -> DirtyClient:
682 """
683 Get or create a thread-local sync client.
684
685 This is the recommended way to get a client in sync HTTP workers.
686
687 Args:
688 timeout: Timeout for operations in seconds
689
690 Returns:
691 DirtyClient: Thread-local client instance
692
693 Example::
694
695 from gunicorn.dirty import get_dirty_client
696
697 def my_view(request):
698 client = get_dirty_client()
699 result = client.execute("myapp.ml:MLApp", "inference", data)
700 return result
701 """
702 client = getattr(_thread_local, 'dirty_client', None)
703 if client is None:
704 socket_path = get_dirty_socket_path()
705 client = DirtyClient(socket_path, timeout=timeout)
706 _thread_local.dirty_client = client
707 return client
708
709
710async def get_dirty_client_async(timeout=30.0) -> DirtyClient:

Callers 7

get_clientMethod · 0.90
applicationFunction · 0.90
appFunction · 0.90
embedFunction · 0.90
appFunction · 0.90

Calls 2

get_dirty_socket_pathFunction · 0.85
DirtyClientClass · 0.85

Tested by 3

get_clientMethod · 0.72