Skip to content

🐛 fix: make internal threads daemon to prevent shutdown hang#22

Open
vidonnus wants to merge 1 commit intoiwalton3:masterfrom
vidonnus:fix-daemon-threads
Open

🐛 fix: make internal threads daemon to prevent shutdown hang#22
vidonnus wants to merge 1 commit intoiwalton3:masterfrom
vidonnus:fix-daemon-threads

Conversation

@vidonnus
Copy link

Summary

  • Make WindowsSocket, UnixSocket, and EventHandler threads daemon threads

Problem

When MPV is killed externally (e.g., Cmd+Q on macOS), the non-daemon threads block on I/O operations (socket.recv(), queue.get()) and Python's interpreter shutdown waits for them indefinitely. This causes applications using this library to hang for minutes until MPV fully exits.

Solution

Setting self.daemon = True on all internal threads allows Python to exit cleanly without waiting for these threads to finish.

When MPV is killed externally, non-daemon threads block on I/O operations
and Python's interpreter shutdown waits for them indefinitely. Setting
daemon=True allows Python to exit cleanly without waiting for these threads.
F0903 added a commit to F0903/python-mpv-jsonipc that referenced this pull request Feb 4, 2026
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.

1 participant