Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-272

In pymongo/connection.py, function _closed can be simplified

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.0
    • 2.1
    • None
    • None
    • Fully Compatible

    Description

      Function _closed(sock) uses sock.recv() without parameters, which always raises a TypeError and thus if there's data in the socket it will return True anyway. This patch removes the call to sock.recv() because it is not needed, what's worse is that would it ever succeed some data would be removed from the socket and its state would become inconsistent.

      So the only check needed is to check if len(rd) is non-zero, because if it is the socket is either closed or has unexpected data, in either case it cannot be used safely.

      Attachments

        Activity

          People

            bernie@mongodb.com Bernie Hackett
            snaury Alexey Borzenkov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: