Skip to content

Conversation

@slicklash
Copy link
Contributor

Problem

Sometimes gprofilter hangs

Causes

sometimes start_process (Popen) hangs because of preexec_fn

Caution

The preexec_fn parameter is NOT SAFE to use in the presence of threads in your application. The child process could deadlock before exec is called. https://docs.python.org/3/library/subprocess.html#popen-constructor

Solution

replace preexec_fn with start_new_session flag and introduce pdeathsigger

tests/utils.py Outdated
last_snapshot = profiler.snapshot()
return pid in last_snapshot

wait_event(timeout=5, stop_event=Event(), condition=has_profile, interval=0.1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this will try to snapshot() every 100ms? I don't think we can do snapshots that fast, it is a very heavy operation. If the issue is that pids do not appear fast enough in snapshots (what is the underlying reason 🤔 ? I see it's independent of runtime) then I'd be more comfortable sticking a sleep(2) before profiler.snapshot() instead of calling snapshot multiple times in a row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants