Fix the dummy provider

Make the dummy provider behave a bit more like the other providers, with
a proper function and termination logic. This will be helpful soon in
the tests.
This commit is contained in:
Alex Pyrgiotis 2024-09-26 17:37:02 +03:00
parent d6410652cb
commit dc8a22c8e7
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA

View file

@ -8,7 +8,7 @@ from typing import Callable, Optional
from ..document import Document from ..document import Document
from ..util import get_resource_path from ..util import get_resource_path
from .base import IsolationProvider from .base import IsolationProvider, terminate_process_group
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -27,6 +27,7 @@ class Dummy(IsolationProvider):
"Dummy isolation provider is UNSAFE and should never be " "Dummy isolation provider is UNSAFE and should never be "
+ "called in a non-testing system." + "called in a non-testing system."
) )
super().__init__()
def install(self) -> bool: def install(self) -> bool:
return True return True
@ -73,12 +74,19 @@ class Dummy(IsolationProvider):
pass pass
def start_doc_to_pixels_proc(self, document: Document) -> subprocess.Popen: def start_doc_to_pixels_proc(self, document: Document) -> subprocess.Popen:
return subprocess.Popen("True", start_new_session=True) dummy_cmd = ["python3", "-c", "print('The cake is a lie')"]
return subprocess.Popen(
dummy_cmd,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=self.proc_stderr,
start_new_session=True,
)
def terminate_doc_to_pixels_proc( def terminate_doc_to_pixels_proc(
self, document: Document, p: subprocess.Popen self, document: Document, p: subprocess.Popen
) -> None: ) -> None:
pass terminate_process_group(p)
def get_max_parallel_conversions(self) -> int: def get_max_parallel_conversions(self) -> int:
return 1 return 1