Skip to content

Updates from Python SVN, part 4

The most relevant change since the last update is the new function socket.create_connect(). It’s an helper function easing the creation of a connected socket to a given address (the usual host+port tuple) with an optional timeout.

The function is currently being used throughout some network related modules in the standard library.

Its implementation is very straightforward:

loop over getaddrinfo's sequences:
  create the object socket
  set the timeout if any
  connect to the remote address
  return the connected socket if everything went well

At this time it’s being used in ftplib.py, httplib.py, telnetlib.py, poplib.py and smtplib.py.

Thanks to that you can set a timeout directly during the instantiation of these classes: HTTPConnection, FTP, POP3, SMTP and Telnet.

A new kind of temp file in tempfile.py also appeared in the stdlib: SpooledTemporaryFile.

Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • Facebook
  • Twitter
  • Google Bookmarks
  • FriendFeed
  • Google Buzz
  • HackerNews
  • Posterous
  • Reddit
  • Slashdot
  • Tumblr
  • http://e-scribe.com/news/ Paul

    Thanks for doing these updates, Lawrence. It’s nice to follow these changes in quasi-real-time.