diff --git a/src/calibre/srv/loop.py b/src/calibre/srv/loop.py index 95993c16cc..0a15cc1167 100644 --- a/src/calibre/srv/loop.py +++ b/src/calibre/srv/loop.py @@ -15,13 +15,12 @@ from calibre.ptempfile import TemporaryDirectory from calibre.srv.opts import Options from calibre.srv.utils import ( socket_errors_socket_closed, socket_errors_nonblocking, HandleInterrupt, - socket_errors_eintr, start_cork, stop_cork) + socket_errors_eintr, start_cork, stop_cork, DESIRED_SEND_BUFFER_SIZE) from calibre.utils.socket_inheritance import set_socket_inherit from calibre.utils.logging import ThreadSafeLog from calibre.utils.monotonic import monotonic READ, WRITE, RDWR = 'READ', 'WRITE', 'RDWR' -DESIRED_SEND_BUFFER_SIZE = 16 * 1024 class Connection(object): diff --git a/src/calibre/srv/tests/http.py b/src/calibre/srv/tests/http.py index c4e4d6daaf..d1d5c2cc34 100644 --- a/src/calibre/srv/tests/http.py +++ b/src/calibre/srv/tests/http.py @@ -329,6 +329,7 @@ class TestHTTP(BaseTest): self.ae(len(data), len(rdata)) self.ae(hashlib.sha1(data).hexdigest(), hashlib.sha1(rdata).hexdigest()) self.ae(data, rdata) - self.assertLess(monotonic() - start_time, 1, 'Large file transfer took too long') + time_taken = monotonic() - start_time + self.assertLess(time_taken, 1, 'Large file transfer took too long') # }}} diff --git a/src/calibre/srv/utils.py b/src/calibre/srv/utils.py index cb6602db69..174addfa70 100644 --- a/src/calibre/srv/utils.py +++ b/src/calibre/srv/utils.py @@ -17,6 +17,7 @@ from calibre.constants import iswindows HTTP1 = 'HTTP/1.0' HTTP11 = 'HTTP/1.1' +DESIRED_SEND_BUFFER_SIZE = 16 * 1024 # windows 7 uses an 8KB sndbuf def http_date(timeval=None): return type('')(formatdate(timeval=timeval, usegmt=True))