LSSTDESC / imSim

GalSim based Rubin Observatory image simulation package
https://lsstdesc.org/imSim
BSD 3-Clause "New" or "Revised" License
36 stars 15 forks source link

Import LSSTBuilder at file scope #432

Closed jmeyers314 closed 10 months ago

jmeyers314 commented 10 months ago

While trying to run ImSim with multiprocessing (on ARM MacOS) as part of the AOS ts_imsim, I encountered the error:

objc[26896]: +[NSCheapMutableString initialize] may have been in progress in another thread when fork() was called.
objc[26896]: +[NSCheapMutableString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

I tracked the origin of this error to a from batoid_rubin import LSSTBuilder statement within telescope_loader.py. On a whim, I decided to try moving the import to file-level instead of function-level, and that actually seems to solve things. Must be something about having the parent process doing the import and then forking vs forking first and importing in each subprocess? So not entirely sure what's going on, but the change here feels pretty minor and does seem to work.