-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drain the Rust client when its last copy in Python is dropped. (#1334)
If the Python application wants to exit (or the client just gets garbage collected), we want to finish sending any batched requests before proceeding with the GC or app shutdown. Normally, Python will make sure to shut down any Python-side threads before allowing the program to exit. But it's completely unaware of Rust's own threads, so it can't shut them down or wait for them. This is why we need to explicitly make sure they complete their work and shut down on their own. The `Drop` trait in Rust runs when the value is dropped, and we ensure we shut down the background threads *only* when we're certain the only `Arc` copy of the Rust client is the one we're holding (and which is about to go out of scope).
- Loading branch information
1 parent
674b701
commit 7423b35
Showing
6 changed files
with
24 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters