Exemplo n.º 1
0
def ipc_child_f(w, m):
    assert len(get_all_handles()) == 1
    i = start_process(ipc_child_f2, args=(w, m))
    i.join()
    assert i.exitcode == 0
    with raises(GIPCClosed):
        w.close()
Exemplo n.º 2
0
 def test_handlecount(self):
     p = start_process(ipc_handlecounter1, args=(self.rh, self.rh2))
     p.join()
     assert p.exitcode == 0
     # After passing two handles to the child, only 2 must be left open.
     assert len(get_all_handles()) == 2
     self.wh.close()
     self.wh2.close()
Exemplo n.º 3
0
 def test_simple(self):
     h1, h2 = pipe(duplex=True)
     assert len(get_all_handles()) == 4
     h1.put(1)
     h2.put(2)
     assert h2.get() == 1
     assert h1.get() == 2
     h1.close()
     h2.close()
Exemplo n.º 4
0
 def test_single_writer(self):
     r, w = pipe()
     with r as foo:
         fd = foo._fd
     with raises(OSError):
         os.close(fd)
     assert len(get_all_handles()) == 1
     with raises(GIPCClosed):
         r.close()
     w.close()
Exemplo n.º 5
0
def check_for_handles_left_open():
    """Frequently used during test teardown.

    Raise exception if test case left open some file descriptor. Perform
    rigorous close attempts in order to make sure to not leak file descriptors
    during tests.
    """
    handles = get_all_handles()
    if handles:
        for h in handles:
            try:
                h.close()
                os.close(h._fd)
            except (OSError, GIPCError, TypeError):
                pass
        set_all_handles([])
        raise Exception("Test case left open descriptor behind.")
Exemplo n.º 6
0
def ipc_handlecounter1(r1, r2):
    assert len(get_all_handles()) == 2
Exemplo n.º 7
0
 def test_all_handles_length(self):
     assert len(get_all_handles()) == 2