Azure / Azure/azure-functions-python-worker

Graceful shutdown when using the Python worker

Offen
#1,521 1 Kommentar 7 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area:python-functions python
Vorherrschende Sprache
Python
Sterne
357
Forks
116
Ø Merge
32 Min.
Gemergte PRs (30 T.)
1

Beschreibung

#### Is your question related to a specific version? If so, please specify:

The question is not related to a specific version.

#### What binding does your question apply to, if any? (e.g. Blob Trigger, Event Hub Binding, etc)

HTTP trigger

#### Question

The [best practices for Azure Functions](https://learn.microsoft.com/azure/azure-functions/manage-connections?tabs=csharp#static-clients) mention that we should reuse global client instances for better performance with connection pooling. One example also demonstrates the use of [a global Cosmos client instance](https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=asgi%2Capplication-level&pivots=python-mode-decorators#connect-to-a-database) as a pattern.

However, with these global instances, there should be a way to close the connections on a graceful shutdown, prior to stopping the worker.

Another use-case would be to make sure that all telemetry is flushed before the host is (gracefully) shutting down.

Is there any existing documentation that I missed which would explain how to do this in Python? If not, could you provide guidance on how this should be implemented?

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit den verknüpften Azure Functions-Seiten zu Best Practices und zur Python-Referenz und untersuche anschließend den Shutdown-Lebenszyklus des Workers, um festzustellen, ob Python-Code über einen unterstützten Hook für ein ordnungsgemäßes Herunterfahren verfügt. Dokumentiere das unterstützte Verhalten und wie globale Clients oder Telemetrie finalisiert werden sollten, oder halte die fehlende Funktionalität und ihren erwarteten Umfang fest.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, python
Bereich
backend, cloud
Issue-Typ
Dokumentation
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.