Skip to content

Commit 5bb8dd5

Browse files
committed
Fix for queue.statistics bad output
1 parent 0b6dfd1 commit 5bb8dd5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tarantool_queue/tarantool_queue.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -592,19 +592,20 @@ def statistics(self, tube=None):
592592
ans = {}
593593
if stat.rowcount > 0:
594594
for k, v in dict(zip(stat[0][0::2], stat[0][1::2])).iteritems():
595-
k_t = re.split(r'space([^.]*)\.(.*)\.([^.]*)', k)[1:3]
596-
task = False
595+
k_t = list(re.match(r'space([^.]*)\.(.*)\.([^.]*)', k).groups())
597596
if int(k_t[0]) != self.space:
598597
continue
599-
if k_t[-1] in ('total', 'ready', 'delayed', 'taken', 'buried', 'done'):
600-
k_t = map((lambda x: x[::-1]), k_t[1][::-1].split('.', 1))[::-1] + k_t[2:3]
601-
task = True
598+
if k_t[1].endswith('.tasks'):
599+
k_t = k_t[0:1] + k_t[1].split('.') + k_t[2:3]
602600
if not (k_t[1] in ans):
603601
ans[k_t[1]] = {'tasks': {}}
604-
if task:
602+
if len(k_t) == 4:
605603
ans[k_t[1]]['tasks'][k_t[-1]] = v
606-
else:
604+
elif len(k_t) == 3:
607605
ans[k_t[1]][k_t[-1]] = v
606+
else:
607+
raise Queue.ZeroTupleException('stats: \
608+
error when parsing respons')
608609
return ans[tube] if tube else ans
609610

610611
def _touch(self, task_id):

0 commit comments

Comments
 (0)