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

BIND 10 Development do-not-reply at isc.org
Thu Jun 7 08:17:06 UTC 2012


#1828: Python tests print warnings about unclosed file handles / sockets
-------------------------------------+-------------------------------------
                   Reporter:  muks   |                 Owner:  muks
                       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 muks):

 Replying to [comment:16 jinmei]:
 > > 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?

 The changes in this branch should fix the warnings, but not any fd
 exhaustion. None of the warnings printed by Python during the tests point
 to fd exhaustion. The bug itself was created assuming that there was fd
 exhaustion when `close()` was not called (due to the warnings).

 >
 > > > 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").

 You are right. Using the `with` statement is indeed better then, so I'll
 rewrite the patches for this.

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


More information about the bind10-tickets mailing list