andyet / thoonk.py

Persistent (and fast!) push feeds, queues, and jobs leveraging Redis.
Other
355 stars 32 forks source link

Incorrect work with redis.PubSub object #20

Open surabujin opened 10 years ago

surabujin commented 10 years ago

Take simple example:

import sys
import time

import thoonk

def main():
    client = thoonk.Thoonk(listen=True)

    # got exception in ThoonkListener thread
    time.sleep(5)

    print 'Normal exit'

if __name__ == '__main__':
    sys.exit(main())

Output:

$ python thoonk-fail.py 
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
    self.run()
  File "/usr/share/devel/WSA/_env_/local/lib/python2.7/site-packages/thoonk/pubsub.py", line 311, in run
    for event in self._pubsub.listen():
  File "/usr/share/devel/WSA/_env_/local/lib/python2.7/site-packages/redis/client.py", line 1871, in listen
    r = self.parse_response()
  File "/usr/share/devel/WSA/_env_/local/lib/python2.7/site-packages/redis/client.py", line 1815, in parse_response
    response = self.connection.read_response()
AttributeError: 'NoneType' object has no attribute 'read_response'

Normal exit

redis monitor:

1400150988.156461 [0 127.0.0.1:46306] "SUBSCRIBE" "listenerclose_f65d5e305b3941a5a7504a85042666e6" "newfeed" "delfeed" "conffeed"
1400150988.156690 [0 127.0.0.1:46307] "SMEMBERS" "feeds"
1400150988.156954 [0 127.0.0.1:46306] "UNSUBSCRIBE"
$ redis-server --version
Redis server v=2.8.9 sha=00000000:0 malloc=jemalloc-3.2.0 bits=64 build=4b22cefc161c6bbf

PS Is project alive?