(self)
| 940 | t.join() |
| 941 | |
| 942 | def test_send_buffer_timeout(self): |
| 943 | try: |
| 944 | self._has_run_once_timeout |
| 945 | except AttributeError: |
| 946 | # At the moment, this test leaks a few references. |
| 947 | # It looks like the leak originates with the addition |
| 948 | # of _channels.send_buffer() (gh-110246), whereas the |
| 949 | # tests were added afterward. We want this test even |
| 950 | # if the refleak isn't fixed yet, so we skip here. |
| 951 | raise unittest.SkipTest('temporarily skipped due to refleaks') |
| 952 | else: |
| 953 | self._has_run_once_timeout = True |
| 954 | |
| 955 | obj = bytearray(b'spam') |
| 956 | |
| 957 | with self.subTest('non-blocking with timeout'): |
| 958 | cid = _channels.create(REPLACE) |
| 959 | with self.assertRaises(ValueError): |
| 960 | _channels.send_buffer(cid, obj, blocking=False, timeout=0.1) |
| 961 | |
| 962 | with self.subTest('timeout hit'): |
| 963 | cid = _channels.create(REPLACE) |
| 964 | with self.assertRaises(TimeoutError): |
| 965 | _channels.send_buffer(cid, obj, blocking=True, timeout=0.1) |
| 966 | with self.assertRaises(_channels.ChannelEmptyError): |
| 967 | received = recv_nowait(cid) |
| 968 | print(repr(received)) |
| 969 | |
| 970 | with self.subTest('timeout not hit'): |
| 971 | cid = _channels.create(REPLACE) |
| 972 | def f(): |
| 973 | recv_wait(cid) |
| 974 | t = threading.Thread(target=f) |
| 975 | t.start() |
| 976 | _channels.send_buffer(cid, obj, blocking=True, timeout=10) |
| 977 | t.join() |
| 978 | |
| 979 | def test_send_closed_while_waiting(self): |
| 980 | obj = b'spam' |
nothing calls this directly
no test coverage detected