This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Zahari.Dim
Recipients Zahari.Dim, belopolsky, christian.heimes, eric.smith, gaborjbernat,, lukasz.langa, martin.panter, orsenthil, pablogsal, remi.lapeyre, rhettinger, terry.reedy, tim.peters, tshepang
Date 2020-01-19.14:03:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I would like to suggest a `dependency_resolver` API that I have been using that goes in line with what Tim Peters proposes in

A DAG would be an object that can be iterated in topological order with __iter__ (for simple sequential usage) or have a way of managing all the tasks that can be run in parallel. The later is done with a generator function:

    def dependency_resolver(self):
        """Yield the set of nodes that have all dependencies satisfied (which could be an empty set). Send the next
        completed task."""

which is used with something like:

deps = dag.dependency_resolver()
pending_tasks = deps.send(None)
if not pending_tasks:
    #Graph empty
#Note this is a can be done in parallel/async
while True:
    some_task = pending_tasks.pop()
       more_tasks = deps.send(some_task)
    except StopIteration:
       #Exit when we have sent in all the nodes in the graph
        pending_tasks |= more_tasks


An implementation I have used for some time is here:

although I'd make simpler now. In practice I have found that the function I use most of the time to build the graph is:

dag.add_or_update_node(node=something_hashable, inputs={set of existing nodes}, outputs={set of existing nodes}).

which adds the node to the graph if it was not there and maps updates the dependencies to add inputs and outputs, which in my experience matches the way one discovers dependencies for things like packages.
Date User Action Args
2020-01-19 14:03:43Zahari.Dimsetrecipients: + Zahari.Dim, tim.peters, rhettinger, terry.reedy, belopolsky, orsenthil, eric.smith, christian.heimes, lukasz.langa, tshepang,, martin.panter, pablogsal, remi.lapeyre, gaborjbernat
2020-01-19 14:03:42Zahari.Dimsetmessageid: <>
2020-01-19 14:03:42Zahari.Dimlinkissue17005 messages
2020-01-19 14:03:42Zahari.Dimcreate