MCPcopy Index your code
hub / github.com/python/cpython / test_send_timeout

Method test_send_timeout

Lib/test/test__interpchannels.py:917–940  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

915 self.assertEqual(received, obj)
916
917 def test_send_timeout(self):
918 obj = b'spam'
919
920 with self.subTest('non-blocking with timeout'):
921 cid = _channels.create(REPLACE)
922 with self.assertRaises(ValueError):
923 _channels.send(cid, obj, blocking=False, timeout=0.1)
924
925 with self.subTest('timeout hit'):
926 cid = _channels.create(REPLACE)
927 with self.assertRaises(TimeoutError):
928 _channels.send(cid, obj, blocking=True, timeout=0.1)
929 with self.assertRaises(_channels.ChannelEmptyError):
930 received = recv_nowait(cid)
931 print(repr(received))
932
933 with self.subTest('timeout not hit'):
934 cid = _channels.create(REPLACE)
935 def f():
936 recv_wait(cid)
937 t = threading.Thread(target=f)
938 t.start()
939 _channels.send(cid, obj, blocking=True, timeout=10)
940 t.join()
941
942 def test_send_buffer_timeout(self):
943 try:

Callers

nothing calls this directly

Calls 7

startMethod · 0.95
joinMethod · 0.95
recv_nowaitFunction · 0.85
subTestMethod · 0.45
createMethod · 0.45
assertRaisesMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected