Use proper timeout in test_examples.py
#35
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the broker is slow to terminate, this test may fail. Rather than using
sleep
and polling whether the process has sucessfully terminated, as we’ve done in this test previously, we can instead use thetimeout
argument ofPopen.communicate
to wait for the broker to terminate.This patch does two things: first, it increases the timeout after the broker has been terminated until we decide to kill the broker from 0.1 seconds to 2.0 seconds. This is still a short wait, but it gives a slow broker much more time to gracefully shut down. Second, it switches from
sleep
-and-poll to using thePopen.communicate
function with a timeout to wait until the process has terminated. The exact idiom used in this patch is given in the documentation for this function; the double call tocommunicate
is explained there by the note:Because of this, the two calls to
communicate
are safe, and we only need the output of the latest call.