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()
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()
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)
def exec_delete(token): q = QueuePool.get_queue(token) if q: q.destroy() return json_response()