How I Accidentally Broke Blender While Experimenting with Multiprocessing šŸ˜…
Hey guys! Long time no see!😃
So I tried using the multiprocessing module! My experiments unexpectedly ended up breaking Blender, causing it to crash every time I tried to launch it. I deleted all add-ons, cleared the entire cache, and even attempted to start Blender in factory startup mode—but nothing worked except for completely uninstalling and reinstalling Blender.😭
This might not be entirely correct, but here are some possible reasons why the multiprocessing module didn’t work (based on the error messages I analyzed):
1. Context Access Inside Multiprocessing
  • My implementation directly accesses bpy.context.scene inside the worker function (render_task).
  • This is a problem because bpy.context is not picklable and cannot be passed to subprocesses.
  • Probably Victor just avoided accessing bpy.context inside subprocesses.šŸ¤”
2. Possible Use of spawn Instead of fork
  • On Windows, multiprocessing defaults to spawn, which creates a new interpreter instance for each worker.
  • On Linux/macOS, fork is used instead, which duplicates the process memory—including bpy.
  • If Victor ran the script on Linux/macOS, it may have worked due to fork, while on Windows, bpy becomes unavailable in the subprocess. (So I'm wondering if this is true🧐)
3. Worker Function Placement
  • Victor’s function was defined inside if __name__ == '__main__':, it would prevent Blender from executing multiprocessing code at import time.
  • My current code calls multiprocessing.Pool directly, which can cause Blender to recursively launch itself inside subprocesses.🤪
4. Blender API Restriction: bpy Must Be Used in the Main Thread
  • Blender must be executed in the main thread.
  • My function might be spawning new processes that try to access Blender’s Python API, which causes bpy.context.preferences to fail.
Final Decision
At this point, I’m going to pause my attempts to integrate multiprocessing into the add-on—because I am not ready to keep breaking Blender and reinstalling it every time.šŸ˜…
I also want to avoid causing issues for other users. If I give someone my add-on to test on their PC, I don’t want to accidentally break their Blender too.
Right now, I don’t have enough knowledge (or, honestly, motivation) to dig deeper into fixing this issue. But I wanted to give a heads-up so you can be careful, because something could potentially go wrong. 🚨🤣
2
19 comments
Tetiana Markov
5
How I Accidentally Broke Blender While Experimenting with Multiprocessing šŸ˜…
CG Python Academy (Free)
skool.com/cgpython
3D artists learning Blender Python.
Leaderboard (30-day)
Powered by