A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-March/034185.html below:

[Python-Dev] socket timeouts fail w/ makefile()

[Python-Dev] socket timeouts fail w/ makefile()Skip Montanaro skip@pobox.com
Thu, 20 Mar 2003 21:15:45 -0600
    >> I discovered much to my chagrin today that the socket module's new
    >> timeout capability doesn't play well with file objects as returned by
    >> a socket's makefile method.

    Guido> Can you explain better how it doesn't work?

When the socket is in non-blocking mode, reads on the file returned by
.makefile() will fail with an IOError if there is nothing to return.

    >> I would think the greatest use of timeouts would be using
    >> higher-level line-oriented modules like urllib and ftplib.  In
    >> addition, since makefile() isn't always available, it seems
    >> worthwhile to implement something in socket.py, thus making
    >> makefile() universally available.

    Guido> Um, when is makefile() not available?  

I don't know.  I was going by the doc string in socketmodule.c which says,
in part:

    ...
    makefile([mode, [bufsize]]) -- return a file object for the socket [*]\n\
    ...
     [*] not available on all platforms!");

Maybe the docs are just wrong.  According to the #ifdef in the code, if
NO_DUP is defined (OS/2, Windows, BeOS), makefile() isn't.

    Guido> There's code for Windows that emulates it, returning a file-like
    Guido> object.  Maybe that code should be enabled universally rather
    Guido> than only on Windows...

That sounds similar to what is in timeoutsocket.py.  It would have the
advantage of providing identical semantics across all platforms.

Skip



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4