<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=big5">
<META content="MSHTML 6.00.2800.1458" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>No, I have HTTPSConnection object in each thread.
It seems that the exception happens when all threads try to execute .request()
method for the very first time at the sametime...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>- Joe</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT><BR>><I> Hi,<BR></I>><I> I have a
small program using HTTPSConnection to issue a POST on the<BR></I>><I>
server. When multiple threads of the same program is running, I
got<BR></I>><I> the error:<BR></I>><I> Exception in thread
Thread-3:<BR></I>><I> Traceback (most recent call last):<BR></I>><I> File
"C:\PYTHON23\lib\threading.py", line 436, in __bootstrap<BR></I>><I>
self.run()<BR></I>><I> File "C:\PYTHON23\lib\threading.py", line 416, in
run<BR></I>><I> self.__target(*self.__args, **self.__kwargs)<BR></I>><I>
File "mcstest.py", line 27, in thread_func<BR></I>><I> conn.request("POST",
CGI_PATH, params, headers)<BR></I>><I> File "c:\python23\lib\httplib.py",
line 718, in request<BR></I>><I> self._send_request(method, url, body,
headers)<BR></I>><I> File "c:\python23\lib\httplib.py", line 739, in
_send_request<BR></I>><I> self.endheaders()<BR></I>><I> File
"c:\python23\lib\httplib.py", line 712, in endheaders<BR></I>><I>
self._send_output()<BR></I>><I> File "c:\python23\lib\httplib.py", line 597,
in _send_output<BR></I>><I> self.send(msg)<BR></I>><I> File
"c:\python23\lib\httplib.py", line 564, in send<BR></I>><I>
self.connect()<BR></I>><I> File "c:\python23\lib\httplib.py", line 985, in
connect<BR></I>><I> ssl = socket.ssl(sock, self.key_file,
self.cert_file)<BR></I>><I> File "C:\Python23\lib\socket.py", line 73, in
ssl<BR></I>><I> return _realssl(sock, keyfile, certfile)<BR></I>><I>
sslerror: SSL_CTX_new error<BR></I>><I> in random order. Is there any fix /
patches for this?<BR></I>><I> Regards,<BR></I>><I> - Joe<BR></I><BR>Are
you passing the same HTTPSConnection object to a bunch of threads?<BR>With just
a cursory glance at the httplib module, it doesn't look like<BR>it is thread
safe (meaning I saw no thread imports, no references to<BR>locks, etc.). If, for
some reason, you feel it necessary to pass the<BR>same HTTPSConnection object to
multiple threads, you will probably want<BR>to write a thread-safe wrapper for
HTTPSConnection. I can't think why<BR>you would want to pass the same conn
object to multiple threads rather<BR>than creating a new one per thread - unless
you want to have one and<BR>only one persistent connection among all threads
(using keepalives, I<BR>guess).<BR><BR></DIV></BODY></HTML>