BIND 10 #1828: Python tests print warnings about unclosed file handles / sockets

BIND 10 Development do-not-reply at isc.org
Thu Jun 7 07:51:07 UTC 2012


#1828: Python tests print warnings about unclosed file handles / sockets
-------------------------------------+-------------------------------------
                   Reporter:  muks   |                 Owner:  jinmei
                       Type:         |                Status:  reviewing
  defect                             |             Milestone:
                   Priority:         |  Sprint-20120612
  medium                             |            Resolution:
                  Component:         |             Sensitive:  0
  Unclassified                       |           Sub-Project:  DNS
                   Keywords:         |  Estimated Difficulty:  4
            Defect Severity:  N/A    |           Total Hours:  0
Feature Depending on Ticket:         |
        Add Hours to Ticket:  0      |
                  Internal?:  0      |
-------------------------------------+-------------------------------------

Comment (by jinmei):

 Replying to [comment:15 muks]:

 > > - In "the object goes out of scope" case, the underlying FD should be
 > >   immediately closed (with the warning), so it basically shouldn't
 > >   cause the descriptor exhaustion (as long as the scope is
 > >   sufficiently small), right?
 > > - "these don't happen in a recu(r)sive style..." is not clear to me.
 > >   Are these the points that actually cause the FD exhaustion?
 >
 > None of the cases that print these warnings should cause fd exhaustion
 with CPython.

 Hmm, I'm getting confused.  So the changes in this branch are
 irrelevant to the OpenBSD's FD exhaustion problem?

 > > Regarding the branch itself...
 > >
 > > - (repeating my original comment) I'd suggest using 'file' or
 > >   at least something different from 'fd' to represent file object.
 > > - it would probably be even better to use the `with` idiom so the code
 > >   is more exception safe in terms of the timing of close().  That is,
 > >   instead of
 > > {{{#!python
 > >     file = open(self.pid_file, "w")
 > >     file.write('dummy data\n')
 > >     file.close()
 > > }}}
 > >   do this:
 > > {{{#!python
 > >     # or in this simple case it could be a one-liner.
 > >     with open(self.pid_file, "w") as file:
 > >         file.write('dummy data\n')
 > > }}}
 >
 > This still doesn't call `.close()`.

 The with idiom should mean implicit close(), at least in my
 understanding.  See http://docs.python.org/py3k/library/io.html#module-io
 (and look for "with statement").

-- 
Ticket URL: <http://bind10.isc.org/ticket/1828#comment:16>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development


More information about the bind10-tickets mailing list