diff options
author | Helmut Grohne <helmut@subdivi.de> | 2012-03-17 22:14:47 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2012-03-17 22:14:47 +0100 |
commit | 863e29c4d2ed76ddf35a0bc3b66abe7423125362 (patch) | |
tree | e3c5008f31574a5e84b159b660f38e17d53dfa1e /wsgitools/scgi/forkpool.py | |
parent | 31aef51e3badfd2fdafdc6c15b3a58fcb04607fd (diff) | |
download | wsgitools-863e29c4d2ed76ddf35a0bc3b66abe7423125362.tar.gz |
sendfile support
When a sendfile library is available, expose it via wsgi.file_wrapper.
This support spans both asynchronous and forkpool.
Diffstat (limited to 'wsgitools/scgi/forkpool.py')
-rw-r--r-- | wsgitools/scgi/forkpool.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/wsgitools/scgi/forkpool.py b/wsgitools/scgi/forkpool.py index aa316d1..cdd50f0 100644 --- a/wsgitools/scgi/forkpool.py +++ b/wsgitools/scgi/forkpool.py @@ -12,7 +12,7 @@ import sys import errno import signal -from wsgitools.scgi import _convert_environ +from wsgitools.scgi import _convert_environ, FileWrapper if sys.version_info[0] >= 3: def exc_info_for_raise(exc_info): @@ -444,13 +444,19 @@ class SCGIServer: result = self.wsgiapp(environ, start_response) assert hasattr(result, "__iter__") - assert response_head[0] is not None - result_iter = iter(result) - for data in result_iter: - assert isinstance(data, str) - dumbsend(data) - if response_head[0] != True: + if isinstance(result, FileWrapper) and result.can_transfer(): sendheaders() + sent = 1 + while sent > 0: + sent = result.transfer(con) + else: + assert response_head[0] is not None + result_iter = iter(result) + for data in result_iter: + assert isinstance(data, str) + dumbsend(data) + if response_head[0] != True: + sendheaders() if hasattr(result, "close"): result.close() sfw.close() |