File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments