Skip to content

Commit d159ec5

Browse files
author
Tom Kregenbild
committed
1. Add clear debug prints with queue size (one print every 1000 items in order not to hurt performance) 2. If main queue is empty keep running and do nothing 3. In case of a timeout from main queue restart queue
1 parent a7b5780 commit d159ec5

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

beaver/run_queue.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,27 @@ def run_queue(queue, beaver_config, logger=None):
3131
break
3232

3333
if int(time.time()) - last_update_time > queue_timeout:
34-
logger.info('Queue timeout of "{0}" seconds exceeded, stopping queue'.format(queue_timeout))
34+
logger.info('Main consumer queue timeout of "{0}" seconds exceeded, stopping queue'.format(queue_timeout))
3535
break
3636

3737
try:
3838
if queue.full():
39-
logger.debug("Queue is full")
39+
logger.error("Main consumer queue is full")
40+
4041
else:
41-
logger.debug("Queue Size is: " + str(queue.qsize()))
42-
command, data = queue.get(block=True, timeout=wait_timeout)
43-
if command == "callback":
44-
last_update_time = int(time.time())
45-
logger.debug('Last update time now {0}'.format(last_update_time))
42+
if count == 1000:
43+
logger.debug("Main consumer queue Size is: " + str(queue.qsize()))
44+
count = 0
45+
command, data = queue.get(block=True, timeout=wait_timeout)
46+
if command == "callback":
47+
last_update_time = int(time.time())
48+
logger.debug('Last update time now {0}'.format(last_update_time))
4649
except Queue.Empty:
47-
logger.debug('No data')
48-
continue
50+
if not queue.empty():
51+
logger.error('Recieved timeout from main consumer queue - stopping queue')
52+
break
53+
else:
54+
logger.debug('No data')
4955

5056
if command == 'callback':
5157
if data.get('ignore_empty', False):
@@ -67,15 +73,15 @@ def run_queue(queue, beaver_config, logger=None):
6773
try:
6874
transport.callback(**data)
6975
count += 1
70-
logger.debug("Number of transports: " + str(count))
7176
break
72-
except TransportException:
77+
except TransportException,e:
7378
failure_count = failure_count + 1
7479
if failure_count > beaver_config.get('max_failure'):
7580
failure_count = beaver_config.get('max_failure')
7681

7782
sleep_time = beaver_config.get('respawn_delay') ** failure_count
7883
logger.info('Caught transport exception, reconnecting in %d seconds' % sleep_time)
84+
logger.debug(e)
7985

8086
try:
8187
transport.invalidate()

0 commit comments

Comments
 (0)