On Wed, 13 Oct 2010 05:27:29 -0700 (PDT) Ashish <amvya...@gmail.com> wrote: > > Well, CBSocket is socket implementation that calls my callback on > data. > Both my classes AsyncHTTPSConnection and AsyncHTTPConnection use it > and use it the same way ( self.sock = CBSocket(sock2) ). > The implemetation of AsyncHTTPConnection differs from > AsyncHTTPSConnection only in connect method: sock2 = > ssl.wrap_socket(sock, self.key_file, self.cert_file) > > class CBSocket(asynchat.async_chat): [...]
Ok, this won't work as expected. The first issue is that ssl.wrap_socket() is a blocking operation, where your client will send data and wait for the server reply (it's the SSL's handshake), *before* the socket has been set in non-blocking mode by asyncore. It means that your client will remain idle a lot of time, and explains that neither the client nor the server reach 100% CPU utilization. The second issue is that combining SSL and asyncore is more complicated than that; there are various situations to consider which your code doesn't address. The stdlib right now doesn't provide SSL support for asyncore (see http://bugs.python.org/issue10084 ), so you would have to do it yourself. I don't think it's worth the trouble, and would recommend switching your client to a simple thread-based approach, where you handle each HTTP(S) connection in a separate thread and stick to blocking I/O. Regards Antoine. -- http://mail.python.org/mailman/listinfo/python-list