Harden detached worker module startup
This commit is contained in:
parent
5b43c44dd7
commit
d65b83a140
3 changed files with 12 additions and 3 deletions
8
src/docforge/_projection_worker_main.py
Normal file
8
src/docforge/_projection_worker_main.py
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
"""Private module entry point for the detached projection worker."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from .projection_worker import main
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
raise SystemExit(main())
|
||||||
|
|
@ -201,7 +201,7 @@ def _invoke_worker(request: bytes) -> subprocess.CompletedProcess[bytes]:
|
||||||
"PYTHONUTF8": "1",
|
"PYTHONUTF8": "1",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
command = [sys.executable, "-I", "-m", "docforge.projection_worker"]
|
command = [sys.executable, "-I", "-m", "docforge._projection_worker_main"]
|
||||||
with tempfile.TemporaryFile() as output:
|
with tempfile.TemporaryFile() as output:
|
||||||
completed = subprocess.run(
|
completed = subprocess.run(
|
||||||
command,
|
command,
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ class ProjectionWorkerTests(unittest.TestCase):
|
||||||
command = launched.call_args.args[0]
|
command = launched.call_args.args[0]
|
||||||
options = launched.call_args.kwargs
|
options = launched.call_args.kwargs
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[sys.executable, "-I", "-m", "docforge.projection_worker"],
|
[sys.executable, "-I", "-m", "docforge._projection_worker_main"],
|
||||||
command,
|
command,
|
||||||
)
|
)
|
||||||
self.assertIs(options["shell"], False)
|
self.assertIs(options["shell"], False)
|
||||||
|
|
@ -372,7 +372,7 @@ class ProjectionWorkerTests(unittest.TestCase):
|
||||||
for request in requests:
|
for request in requests:
|
||||||
with self.subTest(length=len(request)):
|
with self.subTest(length=len(request)):
|
||||||
completed = subprocess.run(
|
completed = subprocess.run(
|
||||||
[sys.executable, "-m", "docforge.projection_worker"],
|
[sys.executable, "-I", "-m", "docforge._projection_worker_main"],
|
||||||
cwd=ROOT,
|
cwd=ROOT,
|
||||||
input=request,
|
input=request,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
|
|
@ -381,6 +381,7 @@ class ProjectionWorkerTests(unittest.TestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(2, completed.returncode)
|
self.assertEqual(2, completed.returncode)
|
||||||
self.assertEqual(b"", completed.stdout)
|
self.assertEqual(b"", completed.stdout)
|
||||||
|
self.assertEqual(b"", completed.stderr)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue