summaryrefslogtreecommitdiff
path: root/lib/git/async/graph.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-10 00:24:49 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-10 00:24:49 +0200
commit3323464f85b986cba23176271da92a478b33ab9c (patch)
tree1633f83f6c5fd5a98396fc925b44602282cbd15a /lib/git/async/graph.py
parent257a8a9441fca9a9bc384f673ba86ef5c3f1715d (diff)
downloadgitpython-3323464f85b986cba23176271da92a478b33ab9c.tar.gz
messy first version of a properly working depth-first graph method, which allows the pool to work as expected. Many more tests need to be added, and there still is a problem with shutdown as sometimes it won't kill all threads, mainly because the process came up with worker threads started, which cannot be
Diffstat (limited to 'lib/git/async/graph.py')
-rw-r--r--lib/git/async/graph.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/git/async/graph.py b/lib/git/async/graph.py
index 6386cbaa..e3999cdc 100644
--- a/lib/git/async/graph.py
+++ b/lib/git/async/graph.py
@@ -87,25 +87,26 @@ class Graph(object):
return self
- def visit_input_inclusive_depth_first(self, node, visitor=lambda n: True ):
- """Visit all input nodes of the given node, depth first, calling visitor
- for each node on our way. If the function returns False, the traversal
- will not go any deeper, but continue at the next branch
- It will return the actual input node in the end !"""
- nodes = node.in_nodes[:]
+ def input_inclusive_dfirst_reversed(self, node):
+ """Return all input nodes of the given node, depth first,
+ It will return the actual input node last, as it is required
+ like that by the pool"""
+ stack = [node]
seen = set()
# depth first
- while nodes:
- n = nodes.pop()
+ out = list()
+ while stack:
+ n = stack.pop()
if n in seen:
continue
seen.add(n)
+ out.append(n)
# only proceed in that direction if visitor is fine with it
- if visitor(n):
- nodes.extend(n.in_nodes)
+ stack.extend(n.in_nodes)
# END call visitor
# END while walking
- visitor(node)
+ out.reverse()
+ return out