[Python-Dev] timeoutsocket.py (original) (raw)

Steve Holden sholden@holdenweb.com
Mon, 15 Apr 2002 16:10:41 -0400


Guido wrote:

> [Bernard Yue] > > > What is the status of integrating timeoutsocket.py into standard > > > library? Are there any body responsible for it currently? If not I > > > would like to give it a shot. > > [Guido] > > Isn't one of the problems that the timeout is global? > > [Me] > While there is a global timeout, it can be changed locally before > calling the library modsule that creates a given socket. The normal > mode of usage, of course, is to set a timeout after explicitly > creating each timeoutsocket. Clearly this is no use with opaque > code that creates sockets. > > > Also, I'd expect that if you did this as a standard feature, the > > implementation would be completely different (e.g. integrate it in the > > C socket code). > > > Hmm. That would increase the complexity of the code, given that > socket.c has nested "#ifdef"s and many platform dependencies that > timeoutsocket.py does without. I wouldn't presume to comment on the > difficulty level - it would certainly scare me away, but then I've > avoided C for the past few years as a matter of choice.

Yeah, but the shim layer added by timeoutsocket.py is also something I could do without (especially since there's already a shim layer added by socket.py).

That's something I hadn't thought of. Perhaps Bernard could integrate the timeoutsocket.py code into socket.py? This would need less work than a C rewrite, even with a redesign.

> > I think it would be great if timeouts were added to sockets (and > > maybe the global timeout is even a good thing). But I'd like to see > > a design first rather than code. > > > It could certainly be helpful to network newbies if it were more > difficult to write a program that hangs indefinitely.

But do network newbies really care? They can just ^C their program. I'd have thought that this is mostly useful for the gurus who want to write long-running programs that never get stuck. I guess the newbies only care when they don't understand why they have to ^C. A timeoutsocket error message might provide a helpful explanation. Certainly the main value is for production code.

(Anyway, I'd rather see this discussion on python-dev, where Bernard Yue can see it and others can chime in.) Sorry, my bad for not replying to the list.

regards Steve