コード例 #1
0
ファイル: test_mythread.py プロジェクト: t-8ch/devpi
def test_live(pool):
    class T:
        def thread_run(self):
            self.thread.sleep(100)

    t = T()
    pool.register(t)
    with pool.live():
        assert mythread.has_active_thread(t)
    t.thread.join()
コード例 #2
0
ファイル: test_mythread.py プロジェクト: s-vitaliy/devpi
def test_live(pool):
    class T:
        def thread_run(self):
            self.thread.sleep(100)

    t = T()
    pool.register(t)
    with pool.live():
        assert mythread.has_active_thread(t)
    t.thread.join()
コード例 #3
0
ファイル: test_mythread.py プロジェクト: t-8ch/devpi
def test_start_one(pool):
    class T:
        def thread_run(self):
            self.thread.sleep(100)

    t = T()
    pool.register(t)
    pool.start_one(t)
    assert mythread.has_active_thread(t)
    pool.shutdown()
    t.thread.join()
コード例 #4
0
ファイル: test_mythread.py プロジェクト: s-vitaliy/devpi
def test_start_one(pool):
    class T:
        def thread_run(self):
            self.thread.sleep(100)

    t = T()
    pool.register(t)
    pool.start_one(t)
    assert mythread.has_active_thread(t)
    pool.shutdown()
    t.thread.join()
コード例 #5
0
ファイル: test_mythread.py プロジェクト: t-8ch/devpi
def test_basic_interact(pool, Queue):
    queue1 = Queue()
    queue2 = Queue()
    class T:
        def thread_run(self):
            queue1.put(10)
            queue2.get()
            self.thread.exit_if_shutdown()
            queue2.get()

    t = T()
    pool.register(t)
    pool.start()
    assert queue1.get() == 10
    assert mythread.has_active_thread(t)
    pool.shutdown()
    with pytest.raises(t.thread.pool.Shutdown):
        t.thread.sleep(10)
    queue2.put(20)
    t.thread.join()
    assert not mythread.has_active_thread(t)
コード例 #6
0
ファイル: test_mythread.py プロジェクト: s-vitaliy/devpi
def test_basic_interact(pool, TimeoutQueue):
    queue1 = TimeoutQueue()
    queue2 = TimeoutQueue()

    class T:
        def thread_run(self):
            queue1.put(10)
            queue2.get()
            self.thread.exit_if_shutdown()
            queue2.get()

    t = T()
    pool.register(t)
    pool.start()
    assert queue1.get() == 10
    assert mythread.has_active_thread(t)
    pool.shutdown()
    with pytest.raises(t.thread.pool.Shutdown):
        t.thread.sleep(10)
    queue2.put(20)
    t.thread.join()
    assert not mythread.has_active_thread(t)
コード例 #7
0
ファイル: test_mythread.py プロジェクト: t-8ch/devpi
def test_custom_shutdown(pool, Queue):
    queue1 = Queue()
    class T:
        def thread_shutdown(self):
            queue1.put(10)

        def thread_run(self):
            queue1.get(timeout=None)
            self.thread.exit_if_shutdown()
            queue1.get()

    t = T()
    pool.register(t)
    pool.start()
    assert mythread.has_active_thread(t)
    pool.shutdown()
    t.thread.join()
コード例 #8
0
ファイル: test_mythread.py プロジェクト: s-vitaliy/devpi
def test_custom_shutdown(pool, TimeoutQueue):
    queue1 = TimeoutQueue()

    class T:
        def thread_shutdown(self):
            queue1.put(10)

        def thread_run(self):
            queue1.get(timeout=None)
            self.thread.exit_if_shutdown()
            queue1.get()

    t = T()
    pool.register(t)
    pool.start()
    assert mythread.has_active_thread(t)
    pool.shutdown()
    t.thread.join()