This project is archived and is in readonly mode.
GIL Release in copy_from?
-
Daniele Varrazzo
Hello Walt,
it is surprising
PQgetResultblocks during copy: the IO intensive part of the copy should be performed byPQputCopyData, which releases the gil. However the libpq doc sayPQgetResultis blocking so generally it should be a good idea to release the gil while calling it.Can you test with the attached patch if your application starts working correctly?
Thank you very much.
-
Daniele Varrazzo
Looking at the traceback again, the library is probably not blocked in IO but just locked in the poll waiting for the result to arrive. I think we can just wrap each PGgetResult call into a GIL release (provided we have the connection lock, which should be true but I'll double check) as a tentative way to fix this issue. Walt should let us know in the next days if the patch is good for them anyway.
-
Daniele Varrazzo
- State changed from new to resolved
I've committed a patch for PQgetResult after copy. The other uses of the function shouldn't need it (the most important one is in async code, and by that we should have received the message that it won't block anyway)
I'll mark the issue closed but let me know if it fails to fix the problem.
