-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trace recursively, but only my code #51
Comments
Here's an example of how you can 'blacklist' folders from tracing: import inspect
import os.path
import snoop.tracer
# Paths starting with any value in internal_directories are ignored when tracing
snoop.tracer.internal_directories += (
# Avoid tracing anything in the standard library
os.path.dirname(inspect.__file__),
)
@snoop(depth=5)
def foo():
# This line would normally get traced
source = inspect.getsource(foo)
# Inner function to show that depth is still working
return bar(source)
def bar(s):
return s * 2
foo() |
I think I have a special case which does not work. I start to snoop in a code which should get skipped. Example:
output
I would like to see the Above example is just to have something which can be reproduced. In my real use case I want to start snooping in But I don't want to trace Django, I just want to trace my code. |
I think there's a bug in snoop, my case is that the |
Hi @yantaozhao. This sounds unrelated to the rest of this issue, you should probably open a new one. In any case, I can't see how what you're describing could be a bug in snoop. snoop doesn't control what |
@alexmojaki |
|
@alexmojaki First. Thanks for the snoop and birdseye. |
Thanks for sharing a working example on blacklisting the directories. Most of the time, users need a simple flag to blacklist python standard library as well as third party packages that are installed. If |
That's as easy as a one-liner: from pathlib import Path
import snoop
snoop.tracer.internal_directories += tuple(
map(str, Path(snoop.tracer.internal_directories[0]).parent.glob("*"))
) |
Hi,
I would like to trace the http request handling of Django in my development environment.
But I am sure that the bug is in my code, not in the code of Django.
I would like to see every line of my code, excluding Django, standard library and other libraries.
I had a look at the arguments which
snoop()
accepts, but I think it is not possible up to now.Would you accept a PR which implements this?
Do you have a hint how to implement this?
The text was updated successfully, but these errors were encountered: