[python] Cleanup ThreadPool with atexit rather than __del__ (#5094)

* [python] Cleanup ThreadPool with atexit rather than __del__

This removes the `__del__` function from the generated Python client,
and replaces it with a `cleanup` function. When a ThreadPool is created,
the cleanup function is registered with the `atexit` module.

This fixes #5093, where the API client could hang indefinitely at
garbage collection.

* Update petstore examples

* Test to ensure threadpool is cleaned up

* Docs now encourage using the context manager

* Regenerate docs

* Update samples
This commit is contained in:
Fabian von Feilitzsch
2020-01-28 21:58:11 -08:00
committed by GitHub
parent d627282e89
commit 15345e1620
58 changed files with 2850 additions and 2264 deletions

View File

@@ -20,15 +20,17 @@ import time
import petstore_api
from pprint import pprint
# Create an instance of the API class
api_instance = petstore_api.DefaultApi()
# example, this endpoint has no required or optional parameters
try:
api_response = api_instance.foo_get()
pprint(api_response)
except petstore_api.ApiException as e:
print("Exception when calling DefaultApi->foo_get: %s\n" % e)
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = petstore_api.DefaultApi(api_client)
# example, this endpoint has no required or optional parameters
try:
api_response = api_instance.foo_get()
pprint(api_response)
except petstore_api.ApiException as e:
print("Exception when calling DefaultApi->foo_get: %s\n" % e)
```
### Parameters