What happened (please include outputs or screenshots):
LeaderElection.run sets threading.daemon = True before starting the onstarted_leading worker. That assigns an unused attribute on the threading module; it does not affect the thread. The thread is created without daemon=True, so it inherits the caller's (main thread) non-daemon status and can block interpreter shutdown.
import threading
threading.daemon = True
t = threading.Thread(target=lambda: None)
print(t.daemon) # False
What you expected to happen:
The worker is a daemon thread, created as Thread(target=..., daemon=True).
How to reproduce it (as minimally and precisely as possible):
Run the snippet above; the created thread reports daemon == False.
Environment:
- Kubernetes version (
kubectl version): n/a (client-side)
- OS (e.g., MacOS 10.13.6): any
- Python version (
python --version): 3.12
- Python client version (
pip list | grep kubernetes): master
What happened (please include outputs or screenshots):
LeaderElection.runsetsthreading.daemon = Truebefore starting the onstarted_leading worker. That assigns an unused attribute on the threading module; it does not affect the thread. The thread is created withoutdaemon=True, so it inherits the caller's (main thread) non-daemon status and can block interpreter shutdown.What you expected to happen:
The worker is a daemon thread, created as
Thread(target=..., daemon=True).How to reproduce it (as minimally and precisely as possible):
Run the snippet above; the created thread reports
daemon == False.Environment:
kubectl version): n/a (client-side)python --version): 3.12pip list | grep kubernetes): master