Allow passing thread id to {insert,remove}_real_time_thread · vmprof/vmprof-python@bf1e2db · GitHub
Skip to content

Commit bf1e2db

Browse files
committed
Allow passing thread id to {insert,remove}_real_time_thread
1 parent 8ddc416 commit bf1e2db

3 files changed

Lines changed: 70 additions & 10 deletions

File tree

src/_vmprof.c

Lines changed: 34 additions & 6 deletions

vmprof/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,21 @@ def resolve_addr(addr):
102102
"""
103103
return _vmprof.resolve_addr(addr)
104104

105-
def insert_real_time_thread():
105+
def insert_real_time_thread(thread_id=0):
106106
""" Inserts a thread into the list of threads to be sampled in real time mode.
107107
When enabling real time mode, the caller thread is inserted automatically.
108108
Returns the number of registered threads, or -1 if we can't insert thread.
109+
Inserts the current thread if thread_id is not provided.
109110
"""
110-
return _vmprof.insert_real_time_thread()
111+
return _vmprof.insert_real_time_thread(thread_id)
111112

112-
def remove_real_time_thread():
113+
def remove_real_time_thread(thread_id=0):
113114
""" Removes a thread from the list of threads to be sampled in real time mode.
114115
When disabling in real time mode, *all* threads are removed automatically.
115116
Returns the number of registered threads, or -1 if we can't remove thread.
117+
Removes the current thread if thread_id is not provided.
116118
"""
117-
return _vmprof.remove_real_time_thread()
119+
return _vmprof.remove_real_time_thread(thread_id)
118120

119121

120122
def is_enabled():

vmprof/test/test_run.py

Lines changed: 30 additions & 0 deletions

0 commit comments

Comments
 (0)