Ensure Pipe*Server classes are ready for use after start() returns
This commit is contained in:
		@@ -9,11 +9,14 @@ class PipeIOThread(Thread):
 | 
			
		||||
        self._stop_event = Event()
 | 
			
		||||
        self.__io_threads = []
 | 
			
		||||
 | 
			
		||||
    @terminate_process_on_failure
 | 
			
		||||
    def run(self):
 | 
			
		||||
    def start(self):
 | 
			
		||||
        super().start()
 | 
			
		||||
        self.__io_threads.extend(self._io_threads())
 | 
			
		||||
        for thread in self.__io_threads:
 | 
			
		||||
            thread.start()
 | 
			
		||||
 | 
			
		||||
    @terminate_process_on_failure
 | 
			
		||||
    def run(self):
 | 
			
		||||
        self._stop_event.wait()
 | 
			
		||||
        self._stop_threads()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -224,3 +224,10 @@ def test_assign_message_handler():
 | 
			
		||||
            test_data = token_urlsafe(32).encode()
 | 
			
		||||
            io_pipes.send_message(test_data)
 | 
			
		||||
            assert io_pipes.recv() == test_data * 2
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_write_immediately():
 | 
			
		||||
    for _ in range(10):
 | 
			
		||||
        pipe_io = PipeIOServer(*get_test_init_params())
 | 
			
		||||
        with pipe_io:
 | 
			
		||||
            pipe_io.send_message(b'cica')
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user