forked from bloomberg/memray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Invalidate TLS caches when a Tracker is created
In the child process after a fork, we needed to tell the thread-local Python stack tracker that it was now using a new Tracker, so anything it previously wrote is not in the current output file. Fork isn't the only case where that's required. If a long running thread survives one Tracker being destroyed and a new one being created, that thread must invalidate its cached information about what was already written, since nothing has been written to the new tracker. Make the class that manages the TLS caches detect this case, by keeping a counter of how many trackers have been created in the process, and remembering which tracker its cached information refers to. Before using any cached information it checks if the tracker has been replaced, and invalidates the cache if so.
- Loading branch information
Showing
2 changed files
with
69 additions
and
18 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