Skip to content

timeout socket implementation #36595

Closed
Closed

Description

@mgilfix
mannequin
BPO 555085
Nosy @gvanrossum
Files
  • timeoutsocket.diff
  • test_timeout.py
  • timeoutsocket.patch.2: Version 2 of the timeout socket patch
  • test_timeout.py.2: Version 2 of timeout functionality test
  • socketmodule.c.nb-connect.diff: socketmodule.c:- fix for non-blocking connect not handling EISCONN on non-Windows systems
  • test_socket.py.sendall.diff: test_socket.py:- rejig the sendall() test
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/gvanrossum'
    closed_at = <Date 2002-08-08.20:41:50.000>
    created_at = <Date 2002-05-12.12:11:05.000>
    labels = ['library']
    title = 'timeout socket implementation'
    updated_at = <Date 2002-08-08.20:41:50.000>
    user = 'https://bugs.python.org/mgilfix'

    bugs.python.org fields:

    activity = <Date 2002-08-08.20:41:50.000>
    actor = 'gvanrossum'
    assignee = 'gvanrossum'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2002-05-12.12:11:05.000>
    creator = 'mgilfix'
    dependencies = []
    files = ['4263', '4264', '4265', '4266', '4267', '4268']
    hgrepos = []
    issue_num = 555085
    keywords = ['patch']
    message_count = 12.0
    messages = ['40005', '40006', '40007', '40008', '40009', '40010', '40011', '40012', '40013', '40014', '40015', '40016']
    nosy_count = 3.0
    nosy_names = ['gvanrossum', 'mgilfix', 'aimacintyre']
    pr_nums = []
    priority = 'low'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue555085'
    versions = ['Python 2.3']

    Activity

    1. mgilfix commented on May 12, 2002

      mgilfixmannequin
      MannequinAuthor

      This implements bug bpo-457114 and implements timed socket
      operations. If a timeout is set and the timeout period
      elaspes before the socket operation has finished, a
      socket.error exception is thrown.

      This patch integrates the functionality at two levels:
      the timeout capability is integrated at the C level in
      socketmodule.c. Socket.py was also modified to update
      fileobject creation on a win platform to handle the
      case of the underlying socket throwing an exception.
      The tex documentation was also updated and a new
      regression unit was provided as test_timeout.py.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on May 12, 2002
    3. added
      stdlibStandard Library Python modules in the Lib/ directory
      on May 12, 2002
    4. gvanrossum commented on May 23, 2002

      @gvanrossum
      Member

      Logged In: YES
      user_id=6380

      For a detailed review, see

      http://mail.python.org/pipermail/python-dev/2002-May/024340.html

    5. mgilfix commented on Jun 5, 2002

      mgilfixmannequin
      MannequinAuthor

      Logged In: YES
      user_id=116038

      I've addressed all the issues brought up by Guido. The 2nd
      version of the patch is attached here. In this version, I've
      modified test_socket.py to include tests for the _fileobject
      class in socket.py that was modified by this patch.
      _fileobject needed to be modified so that data would not be
      lost when the underlying socket threw an expection (data was
      no longer accumulated in local variables). The tests for the
      _fileobject class succeed on older versions of python
      (tested 2.1.3) and pass on the newer version of python.

    6. gvanrossum commented on Jun 6, 2002

      @gvanrossum
      Member

      Logged In: YES
      user_id=6380

      Thanks for the new version! I've checked this in. I made
      considerable changes; the following is feedback but you
      don't need to respond because I've addressed all these in
      the checked-in code!

      • Thanks for the cleanup of some non-standard formatting.
        However, it's better not to do this so the diffs don't show
        changes that are unrelated to the timeout patch.

      • You are still importing the select module instead of
        calling select() directly. I really think you should do the
        latter -- the select module has an enormous overhead (it
        allocates several large lists on the heap).

      • Instead of explicitly testing the argument to settimeout
        for being a float, int or long, you should simply call
        PyFloat_AsDouble and handle the error; if someone passes
        another object that implements __float__ that should be
        acceptable.

      • gettimeout() returns sock_timeout without checking if it
        is NULL. It can be NULL when a socket object is never
        initialized. E.g. I can do this:

      >> from socket import *
      >> s = socket.__new__(socket)
      >> s.gettimeout()

      which gives me a segfault. There are probably other places
      where this is assumed.

      • I addressed the latter two issues by making sock_timeout a
        double, whose value is < 0.0 when no timeout is set.
    7. gvanrossum commented on Jun 8, 2002

      @gvanrossum
      Member

      Logged In: YES
      user_id=6380

      Keeping this open as a reminder of things still to finish.

      Most is in the python-dev discussion; Michael Gilfix and
      Bernard Yue have offered to produce more patches.

      One feature we definitely want is a way to specify a timeout
      to be applied to all new sockets.

    8. gvanrossum commented on Jul 18, 2002

      @gvanrossum
      Member

      Logged In: YES
      user_id=6380

      The default timeout is now implemented in CVS.

      There's a bug report from Andrew Macintyre (unfortunately on
      python-dev) about test_socket.py failures on FreeBSD. I'll
      try to keep an eye on that, so this patch *still* stays
      open. Also, Bernie has promised some changes that I haven't
      received yet and the details of which I don't recall (sorry
      :-( ).

    9. mgilfix commented on Jul 23, 2002

      mgilfixmannequin
      MannequinAuthor

      Logged In: YES
      user_id=116038

      Now that I'm back :)

      I checked the archive and this seems to have been handled by
      you. Please let me know if it isn't resolved and I can give
      it a closer look.

      Also, perhaps I should contact Bernie and ask him if there's
      anything he hasn't gotten around to in the test_timeout that
      I can off-load from him.

    10. aimacintyre commented on Jul 30, 2002

      aimacintyremannequin
      Mannequin

      Logged In: YES
      user_id=250749

      In private mail to/from Guido, it appears that the FreeBSD
      issues were in test_socket.py, and have been addressed.

      I still have outstanding issues on OS/2 EMX, which I sent to
      Guido privately but will add here as soon as I can.

    11. mgilfix commented on Jul 30, 2002

      mgilfixmannequin
      MannequinAuthor

      Logged In: YES
      user_id=116038

      If Guido is busy (And I'm sure he is), I'd be willing to
      take a hack at the problem if you could email me privately
      and provide a testing environment (No OS/2 EMX in my apt ;) ).

    12. gvanrossum commented on Jul 30, 2002

      @gvanrossum
      Member

      Logged In: YES
      user_id=6380

      Michael and Andrew, if you can deal with this without my
      involvement I would greatly appreciate it. ;-)

    13. aimacintyre commented on Aug 4, 2002

      aimacintyremannequin
      Mannequin

      Logged In: YES
      user_id=250749

      After discussing the OS/2 issues privately with Michael, the
      outstanding issues are resolved with the socketmodule.c and
      test_socket.py patches I've uploaded here.

      socketmodule.c.nb-connect.diff:
      in the non-blocking connect, OS/2 is returning EINPROGRESS
      from the initial connection attempt, and after the
      internal_select(), the subsequent connection attempt returns
      EISCONN.
      this appears to be perfectly legitimate, although FreeBSD
      and Linux haven't been seen to return the EINPROGRESS.
      the patch adds specific handling for the EISCONN after
      EINPROGRESS case, matching the semantics already in place
      for the Windows version of the code.

      test_socket.py.sendall.diff:
      the existing sendall() test is flawed as the recv() call
      makes no guarantees about waiting for all the data requested.
      OS/2 required a 100ms sleep in the recv loop to get all the
      data.
      rewriting the reciev test to allow for recv() not waiting
      for data still in transit is more correct.

      Note that these interpretations of "correctness" have been
      based on FreeBSD manpages, which is the only sockets
      documentation I currently have.

      If these are acceptable to Guido, and Michael gets to test
      them on Linux, I can relieve Guido of committing them and
      closing this patch.

    14. gvanrossum commented on Aug 8, 2002

      @gvanrossum
      Member

      Logged In: YES
      user_id=6380

      Andrew, I've checked in your patches. I had to review them
      anyway and I decided to rewrite the testSendAll() check to
      be more informative. Thanks!

      If there are other unsolved issues, please open a new bug
      report and assign it to me.

    15. transferred this issue fromon Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    stdlibStandard Library Python modules in the Lib/ directory

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions