Simplify on_stop
This commit is contained in:
parent
1155011b48
commit
ed62c1d01c
@ -1,5 +1,4 @@
|
||||
from threading import Thread, Event
|
||||
from typing import Callable
|
||||
|
||||
from .pipe_reader_thread import PipeReaderThread
|
||||
from .pipe_writer_thread import PipeWriterThread
|
||||
@ -13,7 +12,6 @@ class PipeIOServer(Thread):
|
||||
self._in_pipe, self._out_pipe = in_pipe, out_pipe
|
||||
self._create_pipes(permissions)
|
||||
self._stop_event = Event()
|
||||
self._on_stop = lambda: None
|
||||
self._reader_thread, self._writer_thread = None, None
|
||||
self._io_threads = None
|
||||
|
||||
@ -66,14 +64,10 @@ class PipeIOServer(Thread):
|
||||
thread.stop()
|
||||
Pipe(self.in_pipe).remove()
|
||||
Pipe(self.out_pipe).remove()
|
||||
self._on_stop()
|
||||
self.on_stop()
|
||||
|
||||
def _set_on_stop(self, value):
|
||||
if not isinstance(value, Callable):
|
||||
raise ValueError("Supplied object is not callable!")
|
||||
self._on_stop = value
|
||||
|
||||
on_stop = property(fset=_set_on_stop)
|
||||
def on_stop(self):
|
||||
pass
|
||||
|
||||
def wait(self):
|
||||
self._stop_event.wait()
|
||||
|
Loading…
Reference in New Issue
Block a user