When the keep_alive flag is enabled, the order in which instances were torn down was not consistent with instance dependencies. Instead, it was solely dependent on the order in which instances were requested. This could lead to errors of various kinds, where instances which should still be alive were torn down too early.
Fix this by defining a deterministic order for teardown. This order is constructed from the order in which instances become alive - building on the idea that for an instance to become alive, all its dependencies must have come alive beforehand.
Note that this does not always reflect the order of request() calls, as a requested machine might request dependencies itself before yielding a live instance.
When the
keep_alive
flag is enabled, the order in which instances were torn down was not consistent with instance dependencies. Instead, it was solely dependent on the order in which instances were requested. This could lead to errors of various kinds, where instances which should still be alive were torn down too early.Fix this by defining a deterministic order for teardown. This order is constructed from the order in which instances become alive - building on the idea that for an instance to become alive, all its dependencies must have come alive beforehand.
Note that this does not always reflect the order of
request()
calls, as a requested machine might request dependencies itself before yielding a live instance.