mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
simplify popen
This commit is contained in:
@@ -79,24 +79,16 @@ class Rpc:
|
|||||||
|
|
||||||
def start(self) -> None:
|
def start(self) -> None:
|
||||||
"""Start RPC server subprocess."""
|
"""Start RPC server subprocess."""
|
||||||
|
popen_kwargs = {"stdin": subprocess.PIPE, "stdout": subprocess.PIPE}
|
||||||
if sys.version_info >= (3, 11):
|
if sys.version_info >= (3, 11):
|
||||||
self.process = subprocess.Popen(
|
# Prevent subprocess from capturing SIGINT.
|
||||||
"deltachat-rpc-server",
|
popen_kwargs["process_group"] = 0
|
||||||
stdin=subprocess.PIPE,
|
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
# Prevent subprocess from capturing SIGINT.
|
|
||||||
process_group=0,
|
|
||||||
**self._kwargs,
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self.process = subprocess.Popen(
|
# `process_group` is not supported before Python 3.11.
|
||||||
"deltachat-rpc-server",
|
popen_kwargs["preexec_fn"] = os.setpgrp # noqa: PLW1509
|
||||||
stdin=subprocess.PIPE,
|
|
||||||
stdout=subprocess.PIPE,
|
popen_kwargs.update(self._kwargs)
|
||||||
# `process_group` is not supported before Python 3.11.
|
self.process = subprocess.Popen("deltachat-rpc-server", **popen_kwargs)
|
||||||
preexec_fn=os.setpgrp, # noqa: PLW1509
|
|
||||||
**self._kwargs,
|
|
||||||
)
|
|
||||||
self.id_iterator = itertools.count(start=1)
|
self.id_iterator = itertools.count(start=1)
|
||||||
self.event_queues = {}
|
self.event_queues = {}
|
||||||
self.request_results = {}
|
self.request_results = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user