HOST = support.HOST
SERVER_QUIT = b'QUIT\n'
-TIMEOUT = 3.0
class echo_server(threading.Thread):
c.push(b"I'm not dead yet!" + term)
c.push(SERVER_QUIT)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
- support.join_thread(s, timeout=TIMEOUT)
+ support.join_thread(s)
self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])
c.push(data)
c.push(SERVER_QUIT)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
- support.join_thread(s, timeout=TIMEOUT)
+ support.join_thread(s)
self.assertEqual(c.contents, [data[:termlen]])
c.push(data)
c.push(SERVER_QUIT)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
- support.join_thread(s, timeout=TIMEOUT)
+ support.join_thread(s)
self.assertEqual(c.contents, [])
self.assertEqual(c.buffer, data)
p = asynchat.simple_producer(data+SERVER_QUIT, buffer_size=8)
c.push_with_producer(p)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
- support.join_thread(s, timeout=TIMEOUT)
+ support.join_thread(s)
self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])
data = b"hello world\nI'm not dead yet!\n"
c.push_with_producer(data+SERVER_QUIT)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
- support.join_thread(s, timeout=TIMEOUT)
+ support.join_thread(s)
self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])
c.push(b"hello world\n\nI'm not dead yet!\n")
c.push(SERVER_QUIT)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
- support.join_thread(s, timeout=TIMEOUT)
+ support.join_thread(s)
self.assertEqual(c.contents,
[b"hello world", b"", b"I'm not dead yet!"])
# where the server echoes all of its data before we can check that it
# got any down below.
s.start_resend_event.set()
- support.join_thread(s, timeout=TIMEOUT)
+ support.join_thread(s)
self.assertEqual(c.contents, [])
# the server might have been able to send a byte or two back, but this
self.assertRaises(TypeError, c.push, 'unicode')
c.push(SERVER_QUIT)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
- support.join_thread(s, timeout=TIMEOUT)
+ support.join_thread(s)
self.assertEqual(c.contents, [b'bytes', b'bytes', b'bytes'])
proto.transport.close()
lsock.close()
- support.join_thread(thread, timeout=1)
+ support.join_thread(thread)
self.assertFalse(thread.is_alive())
self.assertEqual(proto.state, 'CLOSED')
self.assertEqual(proto.nbytes, len(message))
raise unittest.SkipTest("test is not helpful for PGO")
-TIMEOUT = 3
HAS_UNIX_SOCKETS = hasattr(socket, 'AF_UNIX')
class dummysocket:
self.assertEqual(cap.getvalue(), data*2)
finally:
- support.join_thread(t, timeout=TIMEOUT)
+ support.join_thread(t)
@unittest.skipUnless(hasattr(asyncore, 'file_wrapper'),
except OSError:
pass
finally:
- support.join_thread(t, timeout=TIMEOUT)
+ support.join_thread(t)
class TestAPI_UseIPv4Sockets(BaseTestAPI):
family = socket.AF_INET
# cleanup the server
self.server.shutdown()
self.server.server_close()
- support.join_thread(self.thread, 3.0)
+ support.join_thread(self.thread)
# Explicitly clear the attribute to prevent dangling thread
self.thread = None
"""
asyncore.loop(poll_interval, map=self._map)
- def stop(self, timeout=None):
+ def stop(self):
"""
Stop the thread by closing the server instance.
Wait for the server thread to terminate.
-
- :param timeout: How long to wait for the server thread
- to terminate.
"""
self.close()
- support.join_thread(self._thread, timeout)
+ support.join_thread(self._thread)
self._thread = None
asyncore.close_all(map=self._map, ignore_all=True)
self.ready.set()
super(ControlMixin, self).serve_forever(poll_interval)
- def stop(self, timeout=None):
+ def stop(self):
"""
Tell the server thread to stop, and wait for it to do so.
-
- :param timeout: How long to wait for the server thread
- to terminate.
"""
self.shutdown()
if self._thread is not None:
- support.join_thread(self._thread, timeout)
+ support.join_thread(self._thread)
self._thread = None
self.server_close()
self.ready.clear()
self.root_logger.removeHandler(self.sock_hdlr)
self.sock_hdlr.close()
if self.server:
- self.server.stop(2.0)
+ self.server.stop()
finally:
BaseTest.tearDown(self)
# one-second timeout on socket.create_connection() (issue #16264).
self.sock_hdlr.retryStart = 2.5
# Kill the server
- self.server.stop(2.0)
+ self.server.stop()
# The logging call should try to connect, which should fail
try:
raise RuntimeError('Deliberate mistake')
"""Shutdown the UDP server."""
try:
if self.server:
- self.server.stop(2.0)
+ self.server.stop()
if self.sock_hdlr:
self.root_logger.removeHandler(self.sock_hdlr)
self.sock_hdlr.close()
"""Shutdown the server."""
try:
if self.server:
- self.server.stop(2.0)
+ self.server.stop()
if self.sl_hdlr:
self.root_logger.removeHandler(self.sl_hdlr)
self.sl_hdlr.close()
self.assertEqual(d['funcName'], ['test_output'])
self.assertEqual(d['msg'], [msg])
- self.server.stop(2.0)
+ self.server.stop()
self.root_logger.removeHandler(self.h_hdlr)
self.h_hdlr.close()
finally:
t.ready.wait(2.0)
logging.config.stopListening()
- support.join_thread(t, 2.0)
+ support.join_thread(t)
def test_listen_config_10_ok(self):
with support.captured_stdout() as output:
block_func)
return self.result
finally:
- support.join_thread(thread, 10) # make sure the thread terminates
+ support.join_thread(thread) # make sure the thread terminates
# Call this instead if block_func is supposed to raise an exception.
def do_exceptional_blocking_test(self,block_func, block_args, trigger_func,
self.fail("expected exception of kind %r" %
expected_exception_class)
finally:
- support.join_thread(thread, 10) # make sure the thread terminates
+ support.join_thread(thread) # make sure the thread terminates
if not thread.startedEvent.is_set():
self.fail("trigger thread ended but event never set")
self.assertEqual(q.get(timeout=TIMEOUT), 5)
self.assertTrue(q.empty())
timer.advance(1000)
- support.join_thread(t, timeout=TIMEOUT)
+ support.join_thread(t)
self.assertTrue(q.empty())
self.assertEqual(timer.time(), 5)
self.assertEqual(q.get(timeout=TIMEOUT), 4)
self.assertTrue(q.empty())
timer.advance(1000)
- support.join_thread(t, timeout=TIMEOUT)
+ support.join_thread(t)
self.assertTrue(q.empty())
self.assertEqual(timer.time(), 4)