python_modules/dagster/dagster/core/execution_plan/child_process_executor.py
def get_next_event(process, queue):
    '''
    This function polls the process until it returns a valid
    item or returns PROCESS_DEAD_AND_QUEUE_EMPTY if it is in
    a state where the process has terminated and the queue is empty

    Warning: if the child process is in an infinite loop. This will
    also infinitely loop.
    '''
    while True:
        try:
            return queue.get(block=True, timeout=TICK)
        except multiprocessing.queues.Empty:
            if not process.is_alive():
                # There is a possibility that after the last queue.get the
                # process created another event and then died. In that case
                # we want to continue draining the queue.
                try:
                    return queue.get(block=False)
                except multiprocessing.queues.Empty:
                    # If the queue empty we know that there are no more events
                    # and that the process has died.
                    return PROCESS_DEAD_AND_QUEUE_EMPTY

    check.failed('unreachable')
def get_next_event(process, queue):
    '''
    This function polls the process until it returns a valid
    item or returns PROCESS_DEAD_AND_QUEUE_EMPTY if it is in
    a state where the process has terminated and the queue is empty

    Warning: if the child process is in an infinite loop. This will
    also infinitely loop.
    '''
    while True:
        try:
            return queue.get(block=True, timeout=TICK)
        except multiprocessing.queues.Empty:
            if not process.is_alive():
                # There is a possibility that after the last queue.get the
                # process created another event and then died. In that case
                # we want to continue draining the queue.
                try:
                    return queue.get(block=False)
                except multiprocessing.queues.Empty:
                    # If the queue empty we know that there are no more events
                    # and that the process has died.
                    return PROCESS_DEAD_AND_QUEUE_EMPTY

    check.failed('unreachable')
This function polls the process until it returns a valid
    item or returns PROCESS_DEAD_AND_QUEUE_EMPTY if it is in
    a state where the process has terminated and the queue is empty

    Warning: if the child process is in an infinite loop. This will
    also infinitely loop.