Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > cunfused why gevent block redis' socket request?

Reply
Thread Tools

cunfused why gevent block redis' socket request?

 
 
Tony Shao
Guest
Posts: n/a
 
      12-29-2012
GOAL:spawn a few greenlet worker deal with the data pop from redis (pop from redis and then put into queue)

RUNNING ENV: ubuntu 12.04
PYTHON VER: 2.7
GEVENT VER: 1.0 RC2
REDIS VER:2.6.5
REDIS-PY VER:2.7.1

from gevent import monkey; monkey.patch_all()
import gevent
from gevent.pool import Group
from gevent.queue import JoinableQueue
import redis

tasks = JoinableQueue()
task_group = Group()

def crawler():
while True:
if not tasks.empty():
print tasks.get()
gevent.sleep()

task_group.spawn(crawler)
redis_client = redis.Redis()
data = redis_client.lpop('test') #<----------Block here
tasks.put(data)


Try to pop data from redis, but it blocked..and no exception raised...just freeze
and remove spawn method ,it will worked..
i feel confuse what happened, plz help!
thk u!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gevent + urllib2 blocking 月忧茗 Python 0 02-22-2013 03:40 PM
concurrent.futures vs gevent subin Python 0 07-29-2012 06:37 PM
why greenlet, gevent or the stackless are needed? self.python Python 4 07-07-2012 03:38 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Fo:Block can you check to see if a block contains any text by using the block id? morrell XML 1 10-10-2006 07:18 PM



Advertisments