diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2011-04-20 18:38:56 +0000 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2011-04-20 18:38:56 +0000 |
commit | 12abd6b088bfc7d75cab26b114f2b1c06455dd83 (patch) | |
tree | 678ea017e9275e8404de97d9e73ff8585ccb45e5 | |
parent | f492d472190048e610755ec8a29260f3cc71606d (diff) | |
download | pysendfile-12abd6b088bfc7d75cab26b114f2b1c06455dd83.tar.gz |
fix small file and trailer tests trapping sendfile() in a loop and exit the loop when it returns 0
-rw-r--r-- | test/test_sendfile.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/test/test_sendfile.py b/test/test_sendfile.py index 7c67b86..7dc184f 100644 --- a/test/test_sendfile.py +++ b/test/test_sendfile.py @@ -254,8 +254,11 @@ class TestSendfile(unittest.TestCase): f.write(_bytes("abcde")) f.close() f = open(TESTFN2, 'rb') - sendfile.sendfile(self.sockno, f.fileno(), 0, 4096, - trailer=_bytes("12345")) + while 1: + sent = sendfile.sendfile(self.sockno, f.fileno(), 0, 4096, + trailer=_bytes("12345")) + if sent == 0: + break self.client.close() self.server.wait() data = self.server.handler_instance.get_data() @@ -322,7 +325,10 @@ class TestSendfile(unittest.TestCase): f.close() f = open(TESTFN2, 'rb') - sendfile_wrapper(self.sockno, f.fileno(), 0, 4096) + while 1: + sent = sendfile_wrapper(self.sockno, f.fileno(), 0, 4096) + if sent == 0: + break self.client.close() if "sunos" in sys.platform: time.sleep(.1) |