mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
fix: use process_group Popen argument with Python 3.11
This commit is contained in:
@@ -2,6 +2,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
from threading import Event, Thread
|
from threading import Event, Thread
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
@@ -35,16 +36,24 @@ class Rpc:
|
|||||||
self.events_thread: Thread
|
self.events_thread: Thread
|
||||||
|
|
||||||
def start(self) -> None:
|
def start(self) -> None:
|
||||||
self.process = subprocess.Popen(
|
if sys.version_info >= (3, 11):
|
||||||
"deltachat-rpc-server",
|
self.process = subprocess.Popen(
|
||||||
stdin=subprocess.PIPE,
|
"deltachat-rpc-server",
|
||||||
stdout=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
# Prevent subprocess from capturing SIGINT.
|
stdout=subprocess.PIPE,
|
||||||
# We are not using `process_group`
|
# Prevent subprocess from capturing SIGINT.
|
||||||
# because it is not supported before Python 3.11.
|
process_group=0,
|
||||||
preexec_fn=os.setpgrp,
|
**self._kwargs,
|
||||||
**self._kwargs,
|
)
|
||||||
)
|
else:
|
||||||
|
self.process = subprocess.Popen(
|
||||||
|
"deltachat-rpc-server",
|
||||||
|
stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
# `process_group` is not supported before Python 3.11.
|
||||||
|
preexec_fn=os.setpgrp, # noqa: PLW1509
|
||||||
|
**self._kwargs,
|
||||||
|
)
|
||||||
self.id = 0
|
self.id = 0
|
||||||
self.event_queues = {}
|
self.event_queues = {}
|
||||||
self.request_events = {}
|
self.request_events = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user