Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close server process pipes #423

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions supriya/scsynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,28 +405,29 @@ def __init__(
self.exit_future: concurrent.futures.Future[int] = concurrent.futures.Future()

def _run_process_thread(self, options: Options) -> None:
self.process = subprocess.Popen(
with subprocess.Popen(
list(options),
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE,
start_new_session=True,
)
read_thread = threading.Thread(
args=(),
daemon=True,
target=self._run_read_thread,
)
read_thread.start()
self.process.wait()
was_quitting = self.status == BootStatus.QUITTING
self.status = BootStatus.OFFLINE
self.exit_future.set_result(self.process.returncode)
if not self.boot_future.done():
self.boot_future.set_result(False)
if was_quitting and self.on_quit_callback:
self.on_quit_callback()
elif not was_quitting and self.on_panic_callback:
self.on_panic_callback()
) as process:
self.process = process
read_thread = threading.Thread(
args=(),
daemon=True,
target=self._run_read_thread,
)
read_thread.start()
self.process.wait()
was_quitting = self.status == BootStatus.QUITTING
self.status = BootStatus.OFFLINE
self.exit_future.set_result(self.process.returncode)
if not self.boot_future.done():
self.boot_future.set_result(False)
if was_quitting and self.on_quit_callback:
self.on_quit_callback()
elif not was_quitting and self.on_panic_callback:
self.on_panic_callback()

def _run_read_thread(self) -> None:
while self.status in (BootStatus.BOOTING, BootStatus.ONLINE):
Expand Down