Permalink
Browse files

explicitly flush all gzip data

On pypy data is buffered to long due to different garbage collection
strategies [0]. By explicitly closing the dummy files those buffers are
flushed and data is not truncated.

[0] (http://doc.pypy.org/en/latest/cpython_differences.html#differences-related-to-garbage-collection-strategies
  • Loading branch information...
1 parent 44423a2 commit dbce62fd1f320e9f1a56e0c31d61e469575e94b2 @t-8ch t-8ch committed Feb 2, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 dummyserver/handlers.py
@@ -149,7 +149,9 @@ def encodingrequest(self, request):
if encoding == 'gzip':
headers = [('Content-Encoding', 'gzip')]
file_ = BytesIO()
- gzip.GzipFile('', mode='w', fileobj=file_).write(data)
+ zipfile = gzip.GzipFile('', mode='w', fileobj=file_)
+ zipfile.write(data)
+ zipfile.close()
data = file_.getvalue()
elif encoding == 'deflate':
headers = [('Content-Encoding', 'deflate')]

0 comments on commit dbce62f

Please sign in to comment.