enthought/distarray — pull request #299 by markkness (2014-04-09 23:11:10+00:00)
Title: More explicit key cleanup in tests.

This PR should be considered as a point for discussion, perhaps to consider with #291, and not necessarily something that should necessarily be merged as is.

It *ought* to be the case, that after running the test suite `make test`, that there are no leftover keys on the engines, which can be shown by running 'make dump_cluster` and seeing zero reported leftovers.

That was once true, but is no longer, `master` at present leaks 472 keys. This PR adds some explicit `context.purge_keys()` calls that clean up many of these, reducing the leak count to 26. The remaining leaks seem to be in two categories:
1) `test_world.py`does not cleanup the `WORLD` context, and this leaves 20 (of the 26) keys.
2) When the context does not use all of the engines, there is a leak on the unused engine. That accounts for the other 6 leaks, 1 in `test_decorator.py`, 3 in `test_distributed_io`, and 2 in `test_context`.

That second behavior, leaks on unused targets, smells of a bug to me, but I have not investigated this further.