Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Wait for all data to be sent before returning it #2

merged 2 commits into from Oct 25, 2012


None yet
3 participants

dbaty commented Oct 24, 2012

As Lorenzo Gil Sanchez reported, tests in test_functional.TestFileWrapper may sometimes fail like this:

Traceback (most recent call last):
  File "/home/damien/dev/waitress/waitress/tests/test_functional.py", line 1043, in test_filelike_longcl_http11
    self.assertEqual(cl, len(response_body))
AssertionError: 45448 != 18000

I could reproduce these test failures on a rather low-end machine. They happen because the data is read from the socket before everything has been sent. The current implementation of read_http() tries to read N bytes; if less than N bytes have been sent at this point, the function returns nevertheless, not waiting for the rest of the data, hence the test failures.

The attached patch should work around this. (Note: this is a "bug" in the tests, not in the implementation.)

dbaty added some commits Oct 24, 2012

Wait for all data to be sent before returning it.
This fixes intermittent failures that may happen on slow machines.

@mcdonc mcdonc merged commit 0bdbbe5 into Pylons:master Oct 25, 2012


mcdonc commented Oct 25, 2012

Thank you!

I confirm this fixes the problem I reported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment