Multiprocessing is slower within Dash

I currently have a Dash app which visualizes summary statistics of biological cell video recordings. The app contains a “download movie clip” button where, upon being clicked, the app calls a function which plots individual frames of the video recording, saves each plot as a PNG file, then strings the PNGs together into a final MP4 file. This MP4 is a clip of the original cell video recording, and is then sent to the user’s local download folder.

The function which plots the frames and saves them as PNGs uses Python’s multiprocessing module to parallelize the process. I’ve noticed that if I run the function standalone in a Jupyter notebook, it works as expected; however, when I run the function within Dash, the multiprocessing is much slower. Generally, the first dozen or so PNG generations is ok, but then the PNG generation becomes slower and slower for subsequent frames.

I haven’t been able to figure out what the issue is since the function works fine outside of Dash but is slower within Dash. Any thoughts on why this is would be greatly appreciated.