Skip to content

Commit fff572f

Browse files
committed
something
1 parent 7f5232e commit fff572f

2 files changed

Lines changed: 40 additions & 15 deletions

File tree

src/rovr/__main__.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -340,19 +340,12 @@ def _get_version() -> list[str]:
340340
if args.force_first_launch:
341341
return
342342

343-
import multiprocessing # noqa: I001
344-
345-
import rovr.monkey_patches._classes # noqa: F401
343+
import rovr.monkey_patches._classes # noqa: F401, I001
346344
import rovr.monkey_patches._platform # noqa: F401
347345

348346
from rovr.functions.config import set_nested_value
349347
from rovr.variables.constants import config
350348

351-
try:
352-
multiprocessing.set_start_method("forkserver", force=True)
353-
except ValueError:
354-
multiprocessing.set_start_method("spawn", force=True)
355-
356349
for feature_path in args.with_features:
357350
set_nested_value(cast(dict, config), feature_path, True)
358351

src/rovr/app.py

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -680,13 +680,45 @@ def watch_for_changes_and_update(self) -> None:
680680
if new_drives != drives():
681681
self.query_one(PinnedSidebar).reload_pins()
682682
except Exception as exc:
683-
self.notify(
684-
f"{type(exc).__name__}: {exc}",
685-
title="Drives Watcher",
686-
severity="warning",
687-
markup=False,
688-
)
689-
dump_exc(self, exc)
683+
if isinstance(exc, ValueError) and "fds_to_keep" in str(exc):
684+
# check spawner
685+
match multiprocessing.get_start_method(allow_none=True):
686+
case None:
687+
# try forkserver
688+
try:
689+
multiprocessing.set_start_method("forkserver")
690+
self.notify(
691+
"multiprocessing is now using forkserver"
692+
)
693+
except ValueError as val_exc:
694+
if "cannot find context" in str(val_exc):
695+
multiprocessing.set_start_method("spawn")
696+
self.notify(
697+
"multiprocessing is now using spawn"
698+
)
699+
case "fork": # theoretically this shouldn't happen
700+
multiprocessing.set_start_method("forkserver")
701+
self.notify("multiprocessing is now using forkserver")
702+
case "forkserver":
703+
multiprocessing.set_start_method("spawn")
704+
self.notify("multiprocessing is now using spawn")
705+
case "spawn":
706+
# nothing else we can do
707+
self.notify(
708+
f"ValueError: {exc}",
709+
title="Drives Watcher (Process)",
710+
severity="error",
711+
markup=False,
712+
)
713+
dump_exc(self, exc)
714+
else:
715+
self.notify(
716+
f"{type(exc).__name__}: {exc}",
717+
title="Drives Watcher",
718+
severity="warning",
719+
markup=False,
720+
)
721+
dump_exc(self, exc)
690722
if i_should_shut_down():
691723
return
692724

0 commit comments

Comments
 (0)