libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.58k stars 382 forks source link

Release GIL in Walker.__next__ #1249

Closed jorio closed 7 months ago

jorio commented 7 months ago

The first call to git_revwalk_next may take a while to complete in large repositories – sometimes a couple of seconds.

This PR releases the Global Interpreter Lock (GIL) during git_revwalk_next to avoid locking up multithreaded applications. (Note: cffi wraps C function calls in a similar fashion.)

A possible use case for this is to keep a GUI application responsive while a background thread is iterating on a Walker. Before this change, pygit2 would hold onto the GIL while calling into git_revwalk_next, causing the UI thread to freeze.