diff --git a/README.md b/README.md index f6f70a8..85e1da4 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ sudo lsof -n -F | python lsofgraph.py | dot -Tjpg > /tmp/a.jpg OR sudo lsof -n -F | python lsofgraph.py | dot -T svg > /tmp/a.svg ```` - or add `unflatten` to the chain for a better layout: ````shell @@ -17,6 +16,7 @@ sudo lsof -n -F | python lsofgraph.py | unflatten -l 1 -c 6 | dot -T jpg > /tmp/ OR sudo lsof -n -F | python lsofgraph.py | unflatten -l 1 -c 6 | dot -T svg > /tmp/a.svg ```` +Note: In cases of handling large datasets, you might encounter a "maximum recursion depth exceeded" error. To work around this, you can increase the recursion limit in your Python environment by adding `sys.setrecursionlimit(15000)` in the `lsofgraph.py` script. ![example output](/example.jpg) diff --git a/lsofgraph.py b/lsofgraph.py index 4b88f3a..b9368ad 100644 --- a/lsofgraph.py +++ b/lsofgraph.py @@ -178,6 +178,10 @@ def print_graph(procs, conns): if __name__ == '__main__': - procs = parse_lsof() - conns = find_connections(procs) - print_graph(procs, conns) + sys.setrecursionlimit(15000) # Increase the recursion limit before processing starts + try: + procs = parse_lsof() + conns = find_connections(procs) + print_graph(procs, conns) + except RuntimeError as e: + print("Error: Recursion depth exceeded. Consider increasing the recursion limit.")