예제 #1
0
    def test_interrupt_wait_for_read_with_event(self):
        rd, wr = self.make_socketpair()

        self.set_alarm(SHORT_SELECT, lambda *args: wr.send(b'x'))
        with self.assertTakesTime(lower=SHORT_SELECT, upper=SHORT_SELECT):
            self.assertEqual([rd], wait.wait_for_read(rd, timeout=LONG_SELECT))
        self.assertEqual(rd.recv(1), b'x')
예제 #2
0
    def test_interrupt_wait_for_read_with_event(self):
        rd, wr = self.make_socketpair()

        self.set_alarm(SHORT_SELECT, lambda *args: wr.send(b'x'))
        with self.assertTakesTime(lower=SHORT_SELECT, upper=SHORT_SELECT):
            self.assertEqual([rd], wait.wait_for_read(rd, timeout=LONG_SELECT))
        self.assertEqual(rd.recv(1), b'x')
예제 #3
0
def test_wait_for_read_write(spair: TYPE_SOCKET_PAIR) -> None:
    a, b = spair

    assert not wait_for_read(a, 0)
    assert wait_for_write(a, 0)

    b.send(b"x")

    assert wait_for_read(a, 0)
    assert wait_for_write(a, 0)

    # Fill up the socket with data
    a.setblocking(False)
    try:
        while True:
            a.send(b"x" * 999999)
    except OSError:
        pass

    # Now it's not writable anymore
    assert not wait_for_write(a, 0)
예제 #4
0
파일: test_wait.py 프로젝트: ctomiao2/vim
def test_wait_for_read_write(spair):
    a, b = spair

    assert not wait_for_read(a, 0)
    assert wait_for_write(a, 0)

    b.send(b"x")

    assert wait_for_read(a, 0)
    assert wait_for_write(a, 0)

    # Fill up the socket with data
    a.setblocking(False)
    try:
        while True:
            a.send(b"x" * 999999)
    except (OSError, socket.error):
        pass

    # Now it's not writable anymore
    assert not wait_for_write(a, 0)
예제 #5
0
def test_wait_for_read_write(spair):
    a, b = spair

    assert not wait_for_read(a, 0)
    assert wait_for_write(a, 0)

    b.send(b"x")

    assert wait_for_read(a, 0)
    assert wait_for_write(a, 0)

    # Fill up the socket with data
    a.setblocking(False)
    try:
        while True:
            a.send(b"x" * 999999)
    except (OSError, socket.error):
        pass

    # Now it's not writable anymore
    assert not wait_for_write(a, 0)
예제 #6
0
    def test_interrupt_wait_for_read_no_event(self):
        rd, wr = self.make_socketpair()

        self.set_alarm(SHORT_SELECT, lambda *args: None)
        with self.assertTakesTime(lower=LONG_SELECT, upper=LONG_SELECT):
            self.assertEqual([], wait.wait_for_read(rd, timeout=LONG_SELECT))
예제 #7
0
 def test_wait_timeout(self):
     rd, wr = self.make_socketpair()
     with self.assertTakesTime(lower=SHORT_SELECT, upper=SHORT_SELECT):
         wait.wait_for_read([rd], timeout=SHORT_SELECT)
예제 #8
0
 def test_wait_for_non_list_iterable(self):
     rd, wr = self.make_socketpair()
     iterable = {'rd': rd}.values()
     self.assertEqual([], wait.wait_for_read(iterable,
                                             timeout=SHORT_SELECT))
예제 #9
0
 def test_wait_for_read_empty(self):
     self.assertEqual([], wait.wait_for_read([], timeout=SHORT_SELECT))
예제 #10
0
 def test_wait_for_read_multiple_socket(self):
     rd, rd2 = self.make_socketpair()
     self.assertEqual([], wait.wait_for_read([rd, rd2],
                                             timeout=SHORT_SELECT))
예제 #11
0
 def test_wait_for_read_multiple_socket(self):
     rd, rd2 = self.make_socketpair()
     self.assertEqual([], wait.wait_for_read([rd, rd2], timeout=SHORT_SELECT))
예제 #12
0
    def test_interrupt_wait_for_read_no_event(self):
        rd, wr = self.make_socketpair()

        self.set_alarm(SHORT_SELECT, lambda *args: None)
        with self.assertTakesTime(lower=LONG_SELECT, upper=LONG_SELECT):
            self.assertEqual([], wait.wait_for_read(rd, timeout=LONG_SELECT))
예제 #13
0
 def test_wait_timeout(self):
     rd, wr = self.make_socketpair()
     with self.assertTakesTime(lower=SHORT_SELECT, upper=SHORT_SELECT):
         wait.wait_for_read([rd], timeout=SHORT_SELECT)
예제 #14
0
 def test_wait_for_non_list_iterable(self):
     rd, wr = self.make_socketpair()
     iterable = {'rd': rd}.values()
     self.assertEqual([], wait.wait_for_read(iterable, timeout=SHORT_SELECT))
예제 #15
0
 def test_wait_for_read_empty(self):
     self.assertEqual([], wait.wait_for_read([], timeout=SHORT_SELECT))
예제 #16
0
 def test_wait_for_read_single_socket(self):
     rd, wr = self.make_socketpair()
     self.assertEqual([], wait.wait_for_read(rd, timeout=SHORT_SELECT))
예제 #17
0
 def test_wait_for_read_single_socket(self):
     rd, wr = self.make_socketpair()
     self.assertEqual([], wait.wait_for_read(rd, timeout=SHORT_SELECT))