Forums

Decompressing InputStream Error

Hey, I believe that my app is raising an error when attempting to read and decompress a mysql blob with StringIO + gzip. The same code is working on my localhost. I get the following error

2014-11-24 10:45:36,153 :IOError: write error

2014-11-24 10:45:36,157 :RuntimeError: generator ignored GeneratorExit

and here are the code lines that likely are the problem:

   import StringIO

   import gzip

   fio = StringIO.StringIO(mystring) # mystring is a string that contains binary data, result of compressing json with gzip and inserting in mysql as binary to blob field

   f = gzip.GzipFile(fileobj=fio)

   jsonstring =  f.read()

Any suggestion or alternatives? I have seen that StringIO has been a reason of conflict particularly to decompress images.

[edit by admin: formatting]

Finally I followed the solution to this thread (https://www.pythonanywhere.com/forums/topic/1366/) and my problem was also solved:

killing the consoles and reloading the app!

[edit by admin: fixed link to go to our site instead of console.ython.org (which mirrors us for boring technical reasons)]

Hi there -- those errors (from the server log, right?) are normal -- it's what our infrastructure prints out when someone connects to your site and then disconnects (clicking away, hitting the browser's "stop" button) before you've finished sending the response. So probably a red herring.

Just to make sure I really understand the solution -- did you just have to reload the app to fix it? Were you seeing any errors apart from the one in the server logs?

Hey, these notifications appeared in the error log, but now I think they can be ignored as the time does not coincide with the time I was testing the app, these coincide effectively with a case of broken pipe. However, neither in the error log nor in the server log do I have an explanation of what happened. I am pretty sure that killing the console/reloading the app solved the problem though.

Right, that makes sense. But was was the problem that you saw?

I added a new method to my code, which fetched binary data from mysql and decompressed it with gzip. At the beginning I would call this method and it raised an error. Now it works fine, although the source code is still the same.

Very odd! Well, so long as it's working now...