You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Not exactly sure since this is exposed in google-ads-python via requests that require user credentials, however the code in this change appears to be the cause. Specifically closing threads in the __del__ method of AuthMetadataPlugin may be causing problems because there are no guarantees around when it's called, and in our case it seems like it may not be called at all.
@lidizheng Could you provide guidance on the best way to implement gRPC's AuthMetadataPlugin.__call__? I think this library's implementation (using threadpools) was modeled closely on grpc/_auth.py.
Thanks for the quick response! A PR would be preferred. I'm also happy to tweak this myself if you can point me in the right direction.
To be completely honest, I have not worked with threading/threadpool, so I was wondering if there was some obvious way to correct this that I was missing. 😅
I have a workaround solution that instead of creating a large number of ThreadPoolExecutors, we can have a global one. Like:
_global_thread_pool=NoneclassAuthMetadataPlugin(...):
def__init__(self, ...):
global_global_thread_pool
...
if_global_thread_poolisNone:
_global_thread_pool=futures.ThreadPoolExecutor() # Let the system default decide number of max_workersself._pool=_global_thread_pool
It solves the spiking number of threads, but not the memory leak issue entirely.
ThreadPoolExecutor is slow and buggy. The thread spawned by it is not daemon thread, but thread with special tags that got clean-up by a registered shutdown handler on interpreter exit. It has caused random hang on exit in gRPC Python.
Activity
busunkim96 commentedon Mar 10, 2020
@lidizheng Could you provide guidance on the best way to implement gRPC's
AuthMetadataPlugin.__call__? I think this library's implementation (using threadpools) was modeled closely on grpc/_auth.py.lidizheng commentedon Mar 10, 2020
Okay. This is a bit awkward.
The code has been out for 3 years, I guess we need to improve its design. I might get back with a PR or a CL? Which one is preferred?
busunkim96 commentedon Mar 10, 2020
Thanks for the quick response! A PR would be preferred. I'm also happy to tweak this myself if you can point me in the right direction.
To be completely honest, I have not worked with threading/threadpool, so I was wondering if there was some obvious way to correct this that I was missing. 😅
lidizheng commentedon Mar 10, 2020
I have a workaround solution that instead of creating a large number of
ThreadPoolExecutors, we can have a global one. Like:It solves the spiking number of threads, but not the memory leak issue entirely.
ThreadPoolExecutoris slow and buggy. The thread spawned by it is not daemon thread, but thread with special tags that got clean-up by a registered shutdown handler on interpreter exit. It has caused random hang on exit in gRPC Python.EDIT: Use class static variable is better.
fix: make threadpool a class var