File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,6 +93,10 @@ def _main_shm_autostart():
9393
9494
9595if __name__ == "__main__" :
96+ # Clear any previous SHM if found
97+ pyarraypool .cleanup_shm ()
98+
99+ # Run main
96100 _main_classic ()
97101 _main_shm_manualmanagement ()
98102 _main_shm_autostart ()
Original file line number Diff line number Diff line change @@ -157,3 +157,17 @@ def object_pool_context() -> Iterator[None]:
157157 yield
158158 finally :
159159 stop_pool ()
160+
161+
162+ def cleanup_shm ():
163+ """Remove previous SHM if any."""
164+ link_path = Path (_CFG_LINK_PATH )
165+ if not link_path .exists ():
166+ return
167+
168+ segment_name = link_path .read_text ().strip ("/" )
169+ segment_path = Path ("/dev/shm" ) / segment_name
170+
171+ LOGGER .info ("Removing SHM segment: %s" , segment_path )
172+ link_path .unlink (missing_ok = True )
173+ segment_path .unlink (missing_ok = True )
You can’t perform that action at this time.
0 commit comments