|
@@ -50,29 +50,14 @@ class QueueListener(object):
|
|
|
log.debug('stop')
|
|
|
self._mQuit = True
|
|
|
|
|
|
- # def _read_queue(self, rclient, queue):
|
|
|
- # while self._mQuit == False:
|
|
|
- # item = rclient.brpop(queue, 1)
|
|
|
- # if item is None:
|
|
|
- # continue
|
|
|
- # else:
|
|
|
- # try:
|
|
|
- # val = json.loads(item[1])
|
|
|
- # method = val['method']
|
|
|
- # params = val['params']
|
|
|
- # self._dispatch(method, params)
|
|
|
- # except Exception as ex:
|
|
|
- # log.error(ex)
|
|
|
- # pass
|
|
|
-
|
|
|
def _read_queue(self, rclient, queue):
|
|
|
while self._mQuit == False:
|
|
|
- item = rclient.rpop(queue)
|
|
|
+ item = rclient.brpop(queue, 1)
|
|
|
if item is None:
|
|
|
- time.sleep(0.1)
|
|
|
+ continue
|
|
|
else:
|
|
|
try:
|
|
|
- val = json.loads(item)
|
|
|
+ val = json.loads(item[1])
|
|
|
method = val['method']
|
|
|
params = val['params']
|
|
|
self._dispatch(method, params)
|
|
@@ -80,6 +65,21 @@ class QueueListener(object):
|
|
|
log.error(ex)
|
|
|
pass
|
|
|
|
|
|
+ # def _read_queue(self, rclient, queue):
|
|
|
+ # while self._mQuit == False:
|
|
|
+ # item = rclient.rpop(queue)
|
|
|
+ # if item is None:
|
|
|
+ # time.sleep(0.1)
|
|
|
+ # else:
|
|
|
+ # try:
|
|
|
+ # val = json.loads(item)
|
|
|
+ # method = val['method']
|
|
|
+ # params = val['params']
|
|
|
+ # self._dispatch(method, params)
|
|
|
+ # except Exception as ex:
|
|
|
+ # log.error(ex)
|
|
|
+ # pass
|
|
|
+
|
|
|
def prepare_data(self):
|
|
|
while self._mQuit == False:
|
|
|
try:
|