From: Phil M. <p.m...@im...> - 2011-11-25 14:01:24
|
On 25/11/11 13:12, Tobias Oberstein wrote: > I am using PyOpenSSL from within Twisted and want to generate new keys without blocking the Twisted networking. > > To do so, I use the deferToThread() Twisted feature, which runs functions on a thread from a background thread pool. > > However, > > PKey.generate_key > > still seems to block everything. > > Does above function lock the GIL? Other way round. The GIL is held unless you explicitly release it, which the current source code for that function does not seem to: http://bazaar.launchpad.net/~exarkun/pyopenssl/trunk/view/head:/OpenSSL/crypto/pkey.c#L39 So AFAICT yes, it will block forever. Perhaps you could shell out to "openssl rsa" in a subprocess. Not ideal, but it won't require source code changes. |