M2Crypto-0.17 blocks python threads?
reizes at gmail.com
reizes at gmail.com
Thu May 31 19:58:29 EDT 2007
I am having a problem with python threads and M2Crypto. It appears
the M2Crypto used in multi-thread application blocks other threads
from running:
Environment: Linux 2.6 (centos 5.0), OpenSSL 0.9.8b, M2Crypto-0.17
I am using echod-thread.py and echo.py as test vehicles.
Start up echod-thread.py
Connect with echo.py - everything looks ok, but connect with second
echo.py and notice that the server does not respond until after the
first echo session is terminated. And yes, echod-thread.py does call
M2Crypto.threading.init()
So my questions are has anyone seen this kind of threading behavior?
If so how did you fix it?
(NOTE: This used to work with old M2Crytpo-0.13)
I edited a version of the server to print some debug messages. Around
the main server loop:
while 1:
print "#### waiting for connection on port 9999"
conn, addr = sock.accept()
thread.start_new_thread(echo_handler, (ctx, conn, addr))
print "#### started thread, main thread sleeping for 2
seconds"
time.sleep(2) # give first session time to start
[tablus at belgrade ssl]$ python echod-thread.py
#### waiting for connection on port 9999
#### started thread, main thread sleeping for 2 seconds
<NOTE: main thread does not continue until thread started with first
echo session terminates!>
< first echo session thread -- works ok>
[tablus at belgrade ssl]$ python echo.py -h belgrade.tablus.com
LOOP: SSL connect: before/connect initialization
LOOP: SSL connect: SSLv3 write client hello A
LOOP: SSL connect: SSLv3 read server hello A
LOOP: SSL connect: SSLv3 read server certificate A
LOOP: SSL connect: SSLv3 read server key exchange A
LOOP: SSL connect: SSLv3 read server done A
LOOP: SSL connect: SSLv3 write client key exchange A
LOOP: SSL connect: SSLv3 write change cipher spec A
LOOP: SSL connect: SSLv3 write finished A
LOOP: SSL connect: SSLv3 flush data
LOOP: SSL connect: SSLv3 read finished A
INFO: SSL connect: SSL negotiation finished successfully
Host = belgrade.tablus.com
Cipher = DHE-RSA-AES256-SHA
Server = /CN=belgrade.tablus.com/ST=CA/C=US/
emailAddress=conalarm_ca at tablus.com/O=Root Certification Authority
Ye Newe Threading Echo Servre
Echo this
Echo this
< second echo session thread -- hangs waiting for server to respond
until first session exits>
[tablus at belgrade ssl]$ python echo.py -h belgrade.tablus.com
LOOP: SSL connect: before/connect initialization
LOOP: SSL connect: SSLv3 write client hello A
More information about the Python-list
mailing list