Open guettli opened 5 years ago
Reliable detection could be tricky - some experimentation across the many different ways of starting a python program is needed I guess.
But right now there is something that can work well for a particular usecase. Since you know your app you also know how your entrypoint can be described. So things like these could be adequate:
From(Q(function="main"), Q(stdlib=False))
From(Q(source_has="if __name__"), Q(stdlib=False))
It would be very nice, if I could ignore all lines which are executing during importing a module.
Unfortunately I think it is hard to tell if a line gets executed because a module gets imported, or because it is actually part of the "real work".
This is useful if you call hunter on the command line like this:
Up to now I can't imagine the matching python code to check if a line is an import or not.
Maybe you have an idea?
One solution: modify the source and add a decorator to the method where tracing should start. But it would be nice if there is a solution without modifying python code.