Commit 4dc3338d authored by Lauren Adoram-Kershner's avatar Lauren Adoram-Kershner Committed by GitHub
Browse files

Merge pull request #379 from ladoramkershner/empty-queue-message

add warning message for empty redis queue
parents fb25a152 c9c30042
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -27,8 +27,14 @@ def pop_computetime_push(queue, inqueue, outqueue):
    msg : dict
          The message from the processing queue.
    """
    # Load the message out of the processing queue and add a max processing time key
    msg = json.loads(queue.rpop(inqueue), object_hook=object_hook)

    # Check if the redis queue is empty
    msg = queue.rpop(inqueue)
    if msg is None:
        return msg

    # if msg is not empty, Load the message out of the processing queue and add a max processing time key
    msg = json.loads(msg, object_hook=object_hook)
    msg['max_time'] = time.time() + slurm_walltime_to_seconds(msg['walltime'])

    # Push the message to the processing queue with the updated max_time
+4 −0
Original line number Diff line number Diff line
@@ -123,4 +123,8 @@ if __name__ == '__main__':
    msg = pop_computetime_push(queue,
                               conf['processing_queue'],
                               conf['working_queue'])
    if msg is None:
        warnings.warn('Expected to process a cluster job, but the message queue is empty.')
        sys.exit()

    main(msg, config)
+4 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import copy
import os
import json
import sys
import warnings

from redis import StrictRedis
import yaml
@@ -50,5 +51,8 @@ if __name__ == '__main__':
    msg = pop_computetime_push(queue,
                               conf['processing_queue'],
                               conf['working_queue'])
    if msg is None:
        warnings.warn('Expected to process a cluster job, but the message queue is empty.')
        sys.exit()

    main(msg, config)
+4 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import copy
import os
import json
import sys
import warnings

from redis import StrictRedis
import yaml
@@ -57,7 +58,9 @@ if __name__ == '__main__':
    msg = pop_computetime_push(queue,
                               conf['processing_queue'],
                               conf['working_queue'])

    if msg is None:
        warnings.warn('Expected to process a cluster job, but the message queue is empty.')
        sys.exit()
    # In order to pop an entry off the queue, we need the exact contents
    #remove_key = copy.deepcopy(msg)

+4 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import copy
import os
import json
import sys
import warnings

from redis import StrictRedis
import yaml
@@ -47,5 +48,8 @@ if __name__ == '__main__':
    msg = pop_computetime_push(queue,
                               conf['processing_queue'],
                               conf['working_queue'])
    if msg is None:
        warnings.warn('Expected to process a cluster job, but the message queue is empty.')
        sys.exit()

    main(msg, config)