Example #1
0
def delete(token):
    queue = QueuePool.get_queue(token)
    if queue:
        for ctr in queue.containers:
            ctr.exec_command('/entrypoint.sh kill ' + token)
        queue.done()
    return json_response()
Example #2
0
def do_exec_with_stream(token, ctr, command, message, timeout=30):
    queue = QueuePool.get_queue(token)
    try:
        for item in ctr.exec_command_with_base64(command, message, timeout=timeout, token=token, stream=True):
            queue.put({'message': item.decode()})
    except Exception as e:
        queue.put({'message': '%s' % e})
    finally:
        queue.done()
Example #3
0
def state(token):
    q = QueuePool.get_queue(token)
    if q is None:
        return json_response(message='No such publish task')
    is_finished = q.finished
    try:
        message = q.get_nowait() if is_finished else q.get(timeout=10)
    except Empty:
        if is_finished:
            message = {'complete': True}
            QueuePool.remove_queue(token)
        else:
            message = {}
    return json_response(message)
Example #4
0
def exec_delete(token):
    q = QueuePool.get_queue(token)
    if q:
        q.destroy()
    return json_response()