vmprof / vmprof-python

vmprof - a statistical program profiler
http://vmprof.com
Other
433 stars 54 forks source link

[Proposal] Allow inserting a different thread by id with `insert_real_time_thread` #201

Closed timpalpant closed 5 years ago

timpalpant commented 5 years ago

When using real-time profiling, the signal is delivered (via broadcasting from the main thread) to the thread that called vmprof.enable(). To register additional threads, we can call insert_real_time_thread.

Currently, this function must be called from each thread that wants to be profiled, and then pthread_self is used to get the caller's thread ID.

Can we add an optional argument to the insert_real_time_thread function that allows registering a different thread by passing its id? This would be convenient in situations where it is difficult to get the desired thread to register itself. For example, we would like to be able to register the worker thread of a web server from a separate control interface.

This change would be backwards compatible, since by default (not passing the argument), the current thread ID would still be used.