(self)
| 3585 | @warnings_helper.ignore_fork_in_thread_deprecation_warnings() |
| 3586 | @support.skip_if_sanitizer("TSan: leaks threads", thread=True) |
| 3587 | def test_rapid_restart(self): |
| 3588 | authkey = os.urandom(32) |
| 3589 | manager = QueueManager( |
| 3590 | address=(socket_helper.HOST, 0), authkey=authkey, |
| 3591 | serializer=SERIALIZER, shutdown_timeout=SHUTDOWN_TIMEOUT) |
| 3592 | try: |
| 3593 | srvr = manager.get_server() |
| 3594 | addr = srvr.address |
| 3595 | # Close the connection.Listener socket which gets opened as a part |
| 3596 | # of manager.get_server(). It's not needed for the test. |
| 3597 | srvr.listener.close() |
| 3598 | manager.start() |
| 3599 | |
| 3600 | p = self.Process(target=self._putter, args=(manager.address, authkey)) |
| 3601 | p.start() |
| 3602 | p.join() |
| 3603 | queue = manager.get_queue() |
| 3604 | self.assertEqual(queue.get(), 'hello world') |
| 3605 | del queue |
| 3606 | finally: |
| 3607 | if hasattr(manager, "shutdown"): |
| 3608 | manager.shutdown() |
| 3609 | |
| 3610 | manager = QueueManager( |
| 3611 | address=addr, authkey=authkey, serializer=SERIALIZER, |
| 3612 | shutdown_timeout=SHUTDOWN_TIMEOUT) |
| 3613 | try: |
| 3614 | manager.start() |
| 3615 | self.addCleanup(manager.shutdown) |
| 3616 | except OSError as e: |
| 3617 | if e.errno != errno.EADDRINUSE: |
| 3618 | raise |
| 3619 | # Retry after some time, in case the old socket was lingering |
| 3620 | # (sporadic failure on buildbots) |
| 3621 | time.sleep(1.0) |
| 3622 | manager = QueueManager( |
| 3623 | address=addr, authkey=authkey, serializer=SERIALIZER, |
| 3624 | shutdown_timeout=SHUTDOWN_TIMEOUT) |
| 3625 | if hasattr(manager, "shutdown"): |
| 3626 | self.addCleanup(manager.shutdown) |
| 3627 | |
| 3628 | |
| 3629 | class FakeConnection: |
nothing calls this directly
no test coverage detected