Skip to content

Commit

Permalink
slapdtest: Ensure server is stopped when the process exits
Browse files Browse the repository at this point in the history
  • Loading branch information
pyldap contributors authored and Petr Viktorin committed Nov 24, 2017
1 parent 42f3e84 commit d54539f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Lib/slapdtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import time
import subprocess
import logging
import atexit
from logging.handlers import SysLogHandler
import unittest

Expand Down Expand Up @@ -151,6 +152,9 @@ def _cleanup_rundir(self):
"""
Recursively delete whole directory specified by `path'
"""
# cleanup_rundir() is called in atexit handler. Until Python 3.4,
# the rest of the world is already destroyed.
import os, os.path
if not os.path.exists(self.testrundir):
return
self._log.debug('clean-up %s', self.testrundir)
Expand Down Expand Up @@ -278,6 +282,7 @@ def start(self):

if self._proc is None:
# prepare directory structure
atexit.register(self.stop)
self._cleanup_rundir()
self.setup_rundir()
self._write_config()
Expand Down

0 comments on commit d54539f

Please sign in to comment.