Keep visualization worker alive until explicit stop
This commit is contained in:
parent
440ca7510f
commit
eb48ba1a51
12 changed files with 410 additions and 150 deletions
|
|
@ -18,6 +18,7 @@ from docforge.project import Project
|
|||
from docforge.visualization import (
|
||||
_GRAPH_BROWSER_HTML,
|
||||
VISUALIZATION_TEMPLATE,
|
||||
PersistentVisualizationRunner,
|
||||
VisualizationIndexSnapshot,
|
||||
VisualizationRunner,
|
||||
)
|
||||
|
|
@ -379,7 +380,7 @@ if (dependencyEdge.source_id !== "dependency" || dependencyEdge.target_id !== "p
|
|||
finally:
|
||||
runner.stop()
|
||||
|
||||
def test_detached_worker_survives_the_launching_transport_process(self) -> None:
|
||||
def test_persistent_worker_survives_launcher_and_stops_only_explicitly(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = self.copy_fixture("alpha", Path(directory))
|
||||
ProjectIndex(Project.open(root)).build()
|
||||
|
|
@ -388,14 +389,9 @@ import sys
|
|||
from pathlib import Path
|
||||
from docforge.index import ProjectIndex
|
||||
from docforge.project import Project
|
||||
from docforge.visualization import DetachedVisualizationRunner
|
||||
from docforge.visualization import PersistentVisualizationRunner
|
||||
|
||||
runner = DetachedVisualizationRunner(
|
||||
ProjectIndex(Project.open(Path(sys.argv[1]))),
|
||||
initial_grace_seconds=1.0,
|
||||
lease_seconds=0.3,
|
||||
monitor_interval_seconds=0.02,
|
||||
)
|
||||
runner = PersistentVisualizationRunner(ProjectIndex(Project.open(Path(sys.argv[1]))))
|
||||
print(runner.start()["url"], flush=True)
|
||||
time.sleep(60)
|
||||
"""
|
||||
|
|
@ -416,8 +412,20 @@ time.sleep(60)
|
|||
self.assertEqual(200, response.status)
|
||||
|
||||
time.sleep(0.6)
|
||||
with self.assertRaises(OSError):
|
||||
urllib.request.urlopen(url, timeout=0.2)
|
||||
with urllib.request.urlopen(url, timeout=2) as response:
|
||||
self.assertEqual(200, response.status)
|
||||
|
||||
runner = PersistentVisualizationRunner(ProjectIndex(Project.open(root)))
|
||||
try:
|
||||
reused = runner.start()
|
||||
self.assertTrue(reused["reused"])
|
||||
self.assertEqual(url.split("?", 1)[0], str(reused["url"]).split("?", 1)[0])
|
||||
stopped = runner.stop()
|
||||
self.assertEqual("stopped", stopped["state"])
|
||||
with self.assertRaises(OSError):
|
||||
urllib.request.urlopen(url, timeout=0.2)
|
||||
finally:
|
||||
runner.stop()
|
||||
|
||||
def test_runner_rejects_ambiguous_targets_and_changed_index_snapshot(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue