2013/10/29 Victor Stinner <victor.stin...@gmail.com>:
> 2013/10/29 Kristján Valur Jónsson <krist...@ccpgames.com>:
>> I was thinking something similar.  It would be useful to be able to "pause" 
>> and "resume"
>> if one is doing any analysis work in the live environment.  This would 
>> reduce the
>> need to have "Filter" objects.
>
> Internally, tracemalloc uses a thread-local variable (called the
> "reentrant" flag) to disable temporarly tracing allocations in the
> current thread. It only disables tracing new allocations,
> deallocations are still proceed.

If I give access to this flag, it would be possible to disable
temporarily tracing in the current thread, but tracing would still be
enabled in other threads. Would it fit your requirement?

Example:
---------------
tracemalloc.enable()
# start your application
...
# spawn many threads
...
# oh no, I don't want to trace this ugly function
tracemalloc.disable_local()
ugly_function()
tracemalloc.enable_local()
...
snapshot = take_snapshot()
---------------

You can imagine a context manager based on these two functions:
---------------
with disable_tracing_temporarily_in_current_thread():
  ugly_function()
---------------

I still don't understand why you would need to stop tracing
temporarily. When I use tracemalloc, I never disable it.

Victor
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to