Re: [Python-Dev] blocking a non-blocking socket

2007-12-08 Thread Audun Ostrem Nordal
> An interesting question has come up in the development of the > SSL module. > > The function ssl.wrap_socket() takes a flag, > do_handshake_on_connect, which tells it whether to do the SSL > handshake before returning an SSLSocket object to the caller. > If the socket being wrapped is non-b

Re: [Python-Dev] blocking a non-blocking socket

2007-12-03 Thread Bill Janssen
Thanks, Audun. If you look at the code, you'll see that both a connect method and a do_handshake method already exist, and work pretty much as you describe. The issue is what to do when the user doesn't use them -- specifies do_handshake_on_connect=True. > Another way of doing it could be to exp

Re: [Python-Dev] blocking a non-blocking socket

2007-12-02 Thread Bill Janssen
> Rather than temporarily > making it blocking by whatever means, some indication needs > to be returned that the operation would block, and a way > provided for the calling code to re-try later. > > If that can't reasonably be done, then passing a non-blocking > socket here should be an error. I

Re: [Python-Dev] blocking a non-blocking socket

2007-12-02 Thread Greg Ewing
Bill Janssen wrote: > What I'd like to do is just use the socket API, > something like: > > blocking = self.getblocking() > try: > self.setblocking(1) > self.do_handshake() > finally: > self.setblocking(blocking) I'm not sure this is the right approach. If the c

Re: [Python-Dev] blocking a non-blocking socket

2007-12-02 Thread Oleg Broytmann
On Sun, Dec 02, 2007 at 12:23:01PM -0800, Bill Janssen wrote: [skip] > Or, should I just set the timeout: > > timeout = self.gettimeout() > try: > self.settimeout(None) > self.do_handshake() > finally: > self.settimeout(timeout) Yes, this is the correct soluti

[Python-Dev] blocking a non-blocking socket

2007-12-02 Thread Bill Janssen
An interesting question has come up in the development of the SSL module. The function ssl.wrap_socket() takes a flag, do_handshake_on_connect, which tells it whether to do the SSL handshake before returning an SSLSocket object to the caller. If the socket being wrapped is non-blocking, the code