Skip to content

fix: hang when movie plugins invoke python - #1315

Open
rogernelson wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
rogernelson:dev/nelsonr/fix_plugin_python_hang
Open

fix: hang when movie plugins invoke python#1315
rogernelson wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
rogernelson:dev/nelsonr/fix_plugin_python_hang

Conversation

@rogernelson

Copy link
Copy Markdown
Contributor

Fix deadlock when MovieIO Plugins invoke Python

Summarize your change.

If a plugin in the MovieIO plugin folder invokes Python in its initialization, a deadlock will occur. This is because the main thread is holding the GIL (global interpreter lock) when the plugins are initialized (in their own threads). If any of these plugins uses Python it will wait on the GIL held by the main thread, which is waiting on its preloader threads to terminate so deadlock will occur.

The cleanest fix for this is to pass callbacks to MovieIO to avoid introducing a Python dependency in it. We'll add one callback to release any resources (optional) and another to re-acquire them (optional). Then we'll call these before and after our blocking wait on the preloader if they are set.

We'll set this in RvApp where we already initialize a bunch of other statics in RvSession. We'll use this to release the GIL (if we are holding it) and reacquire it (if we were holding it before). We'll use a thread_local variable for the GIL state to be correct, even though this shouldn't really ever be called outside of the main thread.

Describe the reason for the change.

To avoid deadlock when loading plugins.

Describe what you have tested and on which operating system.

Mac OS 26.5.1

Add a list of changes, and note any that might need special attention during the review.

If possible, provide screenshots.

Signed-off-by: Roger Nelson <roger.nelson@autodesk.com>
@rogernelson
rogernelson force-pushed the dev/nelsonr/fix_plugin_python_hang branch from 9af832c to 0c67e37 Compare June 23, 2026 16:09
@rogernelson rogernelson changed the title Fix hang when movie plugins invoke python fix: hang when movie plugins invoke python Jun 23, 2026

@bernie-laberge bernie-laberge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thank you @rogernelson !

Signed-off-by: Roger Nelson <roger.nelson@autodesk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants