Re: [Python-Dev] ssl module, non-blocking sockets and asyncore integration

2008-09-18 Thread Giampaolo Rodola'
Some good news: I finally figured out how to modify asyncore to make it properly handle the non-blocking ssl-handshake. I provided a patch for test_ssl.py in issue 3899. Bill, could you please review it? --- Giampaolo http://code.google.com/p/pyftpdlib/ On 18 Set, 00:49, "Giampaolo Rodola'" <[EM

Re: [Python-Dev] ssl module, non-blocking sockets and asyncore integration

2008-09-17 Thread Giampaolo Rodola'
Ok, here's some news, in case they can be of some interest. I managed to write an asyncore disptacher which seems to work. I used my test suite against it and 70 tests passed and 2 failed. The tests failed because at a certain point a call to do_handhsake results in an EOF exception, which is very

Re: [Python-Dev] ssl module, non-blocking sockets and asyncore integration

2008-09-17 Thread Nick Coghlan
Bill Janssen wrote: > Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > >> On Wed, 17 Sep 2008 10:40:01 PDT, Bill Janssen <[EMAIL PROTECTED]> wrote: >>> Ah, now I remember. It seems that sometimes when SSL_ERROR_WANT_READ >>> was returned, things would block; that is, the "handle_read" method on >

Re: [Python-Dev] ssl module, non-blocking sockets and asyncore integration

2008-09-17 Thread Bill Janssen
Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > On Wed, 17 Sep 2008 10:40:01 PDT, Bill Janssen <[EMAIL PROTECTED]> wrote: > >Ah, now I remember. It seems that sometimes when SSL_ERROR_WANT_READ > >was returned, things would block; that is, the "handle_read" method on > >asyncore.dispatcher was n

Re: [Python-Dev] ssl module, non-blocking sockets and asyncore integration

2008-09-17 Thread Jean-Paul Calderone
On Wed, 17 Sep 2008 10:40:01 PDT, Bill Janssen <[EMAIL PROTECTED]> wrote: Ah, now I remember. It seems that sometimes when SSL_ERROR_WANT_READ was returned, things would block; that is, the "handle_read" method on asyncore.dispatcher was never called again, so the SSLSocket.recv() method was nev

Re: [Python-Dev] ssl module, non-blocking sockets and asyncore integration

2008-09-17 Thread Bill Janssen
Ah, now I remember. It seems that sometimes when SSL_ERROR_WANT_READ was returned, things would block; that is, the "handle_read" method on asyncore.dispatcher was never called again, so the SSLSocket.recv() method was never re-called. There are several levels of buffering going on, and I never f

Re: [Python-Dev] ssl module, non-blocking sockets and asyncore integration

2008-09-17 Thread Bill Janssen
Giampaolo Rodola' <[EMAIL PROTECTED]> wrote: > In the meanwhile I noticed something in the ssl.py code which seems to > be wrong: > > def recv (self, buflen=1024, flags=0): > if self._sslobj: > if flags != 0: > raise ValueError( > "non-z

Re: [Python-Dev] ssl module, non-blocking sockets and asyncore integration

2008-09-17 Thread Bill Janssen
Giampaolo Rodola' <[EMAIL PROTECTED]> wrote: > I change my question: how am I supposed to know when the SSL hanshake > is completed? When pending() returns False? When do_handshake() doesn't raise an exception. Bill ___ Python-Dev mailing list Python-D

Re: [Python-Dev] ssl module, non-blocking sockets and asyncore integration

2008-09-17 Thread Bill Janssen
Giampaolo Rodola' <[EMAIL PROTECTED]> wrote: > 2 - By reading ssl.py code I noticed that when do_handshake_on_connect > flag is False the do_handshake() method is never called. Is it > supposed to be manually called when dealing with non-blocking sockets? Yes. Look at the example client in Lib/t

Re: [Python-Dev] ssl module, non-blocking sockets and asyncore integration

2008-09-16 Thread Giampaolo Rodola'
Sorry, ignore my 2nd question, I see now that you already gave a very clear answer in your first message. I change my question: how am I supposed to know when the SSL hanshake is completed? When pending() returns False? If so I'd recommend to document the method. --- Giampaolo http://code.google.

Re: [Python-Dev] ssl module, non-blocking sockets and asyncore integration

2008-09-16 Thread Giampaolo Rodola'
I've tried to modify my existing asyncore-based code but I'm encountering a lot of different problems I didn't manage to fix. It seems that playing with the do_handshake_on_connect flag doesn't make any difference. I guess that without some kind of documentation describing how to deal with non-bloc