Commit 29a6b0c8 authored by Lauren Adoram-Kershner's avatar Lauren Adoram-Kershner
Browse files

add warning message for empty redis queue

parent fb25a152
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
import json
import time
import warnings

import numpy as np

@@ -27,8 +28,15 @@ def pop_computetime_push(queue, inqueue, outqueue):
    msg : dict
          The message from the processing queue.
    """

    # Check if the redis queue is empty
    msg = queue.rpop(inqueue)
    if msg is None:
        warnings.warn('Expected to process a cluster job, but the message queue is empty.')
        sys.exit()

    # 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)
    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