~bzr-pqm/bzr/bzr.dev

Viewing all changes in revision 6133.4.8.

  • Committer: John Arbash Meinel
  • Date: 2011-09-13 17:43:21 UTC
  • mto: (6133.4.49 2.5-soft-hangup-795025)
  • mto: This revision was merged to the branch mainline in revision 6170.
  • Revision ID: john@arbash-meinel.com-20110913174321-and3acxldw7w8eb0
Refactor a bit. Use a common _wait_for_descriptor code.

Changing the loop to use a 'tight' fast-timeout and a 'slow' poll made it
succeed reliably during the test suite. We seem to be getting socket.error(EBADF)
for about 1-in-3 tests. My guess is that it is a race condition when you
have a long timeout in select. If the handle is bad when select() starts, then
you immediately get EBADF. If it is closed on the client, then the server notices
and returns that it can be read without blocking. However, if it is closed on
the server by another thread, after select has started sleeping, select doesn't
end up seeing the status change, and thus has to wait until timeout before
you can then notice the file descriptor doesn't mean anything anymore.

Oddly, about 1 in 1000 tests fail with select.error rather than socket.error.
Even worse, select.error doesn't have an errno attribute (in py 2.7.1), but
only a error.args[0] value.

By doing a fast-select (and setting the timeout *really* low in the test suite),
tests clean up reliably and don't hang for > second. The long poll allows the
test suite to have hiccups/gc/etc without failing a test.

The 4.0s timeout during the test suite is because we have a hard 5.0s 'thread
has hung' timeout. 100ms fast timeout lets us detect shutdown races, and
clean up without waiting for the hard-timeout.

Now to test on Windows, and figure out the configuration story.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: