forked from loafle/openapi-generator-original
[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:
committed by
GitHub
parent
d627282e89
commit
15345e1620
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user