IOError: Stream is closed

190 views
Skip to first unread message

Anderson

unread,
May 20, 2012, 9:43:44 AM5/20/12
to python-...@googlegroups.com
After leaving server idle for couple of minutes and than making a request, i'm getting following error. What can it be?  



Traceback (most recent call last):
      File "/home/apphome/Development/tornadotest/tornado/web.py", line 1074, in wrapper
        return method(self, *args, **kwargs)
      File "/home/apphome/Development/tornadotest/tornado/gen.py", line 107, in wrapper
        runner.run()
      File "/home/apphome/Development/tornadotest/tornado/gen.py", line 319, in run
        yielded = self.gen.throw(*exc_info)
      File "/home/apphome/Development/tornadotest/controllers/login.py", line 27, in post
        player = yield gen.Task(backend.login_player)
      File "/home/apphome/Development/tornadotest/tornado/gen.py", line 341, in run
        self.yield_point.start(self)
      File "/home/apphome/Development/tornadotest/tornado/gen.py", line 223, in start
        self.func(*self.args, **self.kwargs)
      File "/home/apphome/Development/tornadotest/tornado/gen.py", line 107, in wrapper
        runner.run()
      File "/home/apphome/Development/tornadotest/tornado/gen.py", line 319, in run
        yielded = self.gen.throw(*exc_info)
      File "/home/apphome/Development/tornadotest/auth_backends/facebook_backend.py", line 35, in login_player
        player_id = yield gen.Task(redis.get, "pfacebook:%s" % data['user_id'])
      File "/home/apphome/Development/tornadotest/tornado/gen.py", line 341, in run
        self.yield_point.start(self)
      File "/home/apphome/Development/tornadotest/tornado/gen.py", line 223, in start
        self.func(*self.args, **self.kwargs)
      File "/home/apphome/Development/tornadotest/akane/client.py", line 24, in get
        self.send_command(callback, 'GET', key)
      File "/home/apphome/Development/tornadotest/akane/client.py", line 18, in send_command
        conn.send_command(callback, *args)
      File "/home/apphome/Development/tornadotest/akane/connection.py", line 56, in send_command
        self._stream.write(command)
      File "/home/apphome/Development/tornadotest/tornado/iostream.py", line 213, in write
        self._check_closed()
      File "/home/apphome/Development/tornadotest/tornado/iostream.py", line 535, in _check_closed
        raise IOError("Stream is closed")
    IOError: Stream is closed

Costa Farber

unread,
May 21, 2012, 2:48:33 AM5/21/12
to python-...@googlegroups.com
I think timeout was expired. The default is connect_timeout=20.0.

Andrey Shmigelsky

unread,
May 21, 2012, 3:18:56 AM5/21/12
to python-...@googlegroups.com
I measured exact time and it's comes out that after being idle for 5 minutes it throws this error. The connection_timeout is set to 20.0 as you said. 

Александр Приймак

unread,
May 22, 2012, 8:48:09 PM5/22/12
to python-...@googlegroups.com
As far as I understand your server is connected to some kind of backend (I see redis) and connection to this backend somehow is closed after 5 minutes of inactivity.
Did I understand right?

воскресенье, 20 мая 2012 г., 17:43:44 UTC+4 пользователь Anderson написал:

Anderson

unread,
May 23, 2012, 11:18:25 AM5/23/12
to python-...@googlegroups.com
Yes, but the library that i use for connecting to redis don't have code that close iostream it only writes to it. Also i tried to create a "ping" method that run query to redis with cron job every minute. It doesn't help. The interesting part is, half of the queries do work till it hits some specific query. If the query wasn't valid it wouldn't work from beginning, but why it works for five minutes and than stops???? How can i debug it? What is the reason for socket switches to None in IOStream object?

Micheál Keane

unread,
May 23, 2012, 1:43:13 PM5/23/12
to python-...@googlegroups.com
Assuming https://github.com/FSX/akane is what you're using, it looks like it's still in development?

I haven't had any issues with tornado-redis so far.

Washington, DC  USA
ffaris...@gmail.com

Frank Smit

unread,
May 23, 2012, 4:37:47 PM5/23/12
to python-...@googlegroups.com
Ah, didn't notice you're using Akane. Yes, it's still under
development and I'm focusing more on the command and reply parsing at
the moment. And going to try out various things before it's usable for
production. I haven't seen this issue yet, because the connection
doesn't live long enough to time out while testing.

Feel free to test it out and report the bugs you find at
https://github.com/FSX/akane , but don't expect things to be fixed
immediately. I'm not developing this for work or anything related to
that; not getting paid for this. It's just interesting to work on
this. I do intend to write documentation and unit tests when the API
is stabilized.

Regards,
Frank

Andrey Shmigelsky

unread,
May 24, 2012, 5:38:24 AM5/24/12
to python-...@googlegroups.com
Maybe it not worth to use redis asynchronously at all? Or only in situations where i need to save data without waiting for response? I tried standard py-redis and it works way faster than all of async modules. Is the async way is only better for networks with latency problems? If the ping to redis server lets say is 0.1ms, is it rational to use async calls?  

Frank Smit

unread,
May 24, 2012, 6:45:24 AM5/24/12
to python-...@googlegroups.com
That's a good point. I haven't tested that yet. And I guess most time
is spend in the IOLoop/IOStream and not in sending, processing and
receiving data from Redis.
Reply all
Reply to author
Forward
0 new messages