[Python-Dev] ssl module integration with asyncore (original) (raw)

Bill Janssen janssen at parc.com
Tue Nov 27 02:47:34 CET 2007


I downloaded this one: http://pypi.python.org/pypi/ssl/1.12

Yes, that's the one.

...which seems to contain the same test-suite used in the current

Not quite.

Python 2.6 distribution available here: http://svn.python.org/snapshots/ I looked into test/testssl.py but I didn't find any test referencing to the asyncore module. I see a class named "AsyncoreHTTPSServer" but it does not use the asyncore or asynchat modules.

Yes, that's right, it uses SocketServer. But that's very close to the same thing. I'll change the name to make it clear.

Really, the only interesting part is the "get_request" method, which overrides the "get_request" method from SocketServer.TCPServer, and is very similar to the asyncore.dispatcher "accept" method.

You may also need to override the "readable" method on asyncore.dispatcher:

def readable(self):
    if isinstance(self.socket, ssl.SSLSocket):
        # dispatch any bytes left in the SSL buffer
        while self.socket.pending() > 0:
            self.handle_read_event()
    return True

Bill



More information about the Python-Dev mailing list