mirror of
https://github.com/php-win-ext/grpc.git
synced 2026-03-24 00:52:08 +01:00
To avoid data races and use-after-free on shutdown in Python 3.13. It seems to have worked before due to unintended guarantees of the Python interpreter that are gone with the new version. Uses `threading.Event` and `threading.Lock` to coordinate between the main thread handling signals and the `flush_stdout_loop` thread. The `_quit_on_signal` handler now signals the flush thread to exit, and waits for the flush thread to complete its current sleep cycle before calling `sys.exit()`. This prevents a use-after-free that shows up as a data race. Ref b/474047558 PiperOrigin-RevId: 859182150