Skip to content

Commit

Permalink
Avoid ResourceWarnings killing daemons
Browse files Browse the repository at this point in the history
Newever versions of Python explicitly warn in tests when
resources like files are left hanging around (they'll be closed
eventually).  We were being warned about our termination of the
krb5 daemons.

Additionally, the call to `wait()` could potentially deadlock if
the daemon wrote too much to stdout or stderr.

These issues are fixed by using switching to actually using the
`Popen#terminate` method (instead of calling `kill` in the pid),
followed by `Popen#communicate` (instead of just `Popen#wait`).
  • Loading branch information
DirectXMan12 committed Nov 28, 2017
1 parent 591fe16 commit c898e45
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions k5test/realm.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ def start_kdc(self, args=[], env=None):
'starting...')

def _stop_daemon(self, proc):
os.kill(proc.pid, signal.SIGTERM)
proc.wait()
proc.terminate()
proc.communicate()
self._daemons.remove(proc)

def stop_kdc(self):
Expand Down

0 comments on commit c898e45

Please sign in to comment.