Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

fix threaded use of pyinstrument_cext #3

Merged
merged 4 commits into from
Jul 18, 2018
Merged

fix threaded use of pyinstrument_cext #3

merged 4 commits into from
Jul 18, 2018

Conversation

joerick
Copy link
Owner

@joerick joerick commented Jul 17, 2018

@joerick
Copy link
Owner Author

joerick commented Jul 17, 2018

So far, I've just added a failing test case. Next step is to see if I can find a fix.

The first thing to tackle is the module-level state - this should be moved to thread-locals I believe.

State is in a PyObject that's passed to the PyEval_SetProfile function.
This is stored in the thread variables, and passed back whenever the
callback is made.

In this way, setstatprofile can be called from different threads, the
profiling sessions are completely isolated.
@joerick
Copy link
Owner Author

joerick commented Jul 18, 2018

Added a fix that works on my machine. Let's see what the CI makes of it!

@joerick joerick changed the title [WIP] fix threaded use of pyinstrument_cext fix threaded use of pyinstrument_cext Jul 18, 2018
@joerick joerick merged commit 5cae9a7 into master Jul 18, 2018
@joerick joerick deleted the thread-danger branch July 18, 2018 12:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant