예제 #1
0
파일: timeline.py 프로젝트: scorphus/ptvsd
    def __init__(self, ignore_unobserved=None):
        self._ignore_unobserved = ignore_unobserved or []

        self._index_iter = itertools.count(1)
        self._accepting_new = threading.Event()
        self._finalized = threading.Event()
        self._recorded_new = threading.Condition()
        self._record_queue = queue.Queue()

        self._recorder_thread = threading.Thread(target=self._recorder_worker, name='Timeline-%d recorder' % id(self))
        self._recorder_thread.daemon = True
        self._recorder_thread.start()

        # Set up initial environment for our first mark()
        self._last = None
        self._beginning = None
        self._accepting_new.set()

        self._beginning = self.mark('begin')
        assert self._last is self._beginning
        self._proceeding_from = self._beginning
예제 #2
0
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE in the project root
# for license information.

from __future__ import print_function, with_statement, absolute_import

__all__ = ['print', 'wait_for_output']

import threading
from ptvsd.compat import queue
from pytests.helpers import timestamp, colors

real_print = print
print_queue = queue.Queue()


def print(*args, **kwargs):
    """Like builtin print(), but synchronized across multiple threads,
    and adds a timestamp.
    """
    timestamped = kwargs.pop('timestamped', True)
    t = timestamp() if timestamped else None
    print_queue.put((t, args, kwargs))


def wait_for_output():
    print_queue.join()


def print_worker():
    while True: