Example #1
0
    def it_fails_when_there_are_locks(self, tmpdir):
        lockfile = tmpdir.ensure('lock')
        lock = lockfile.open()

        with ShouldRaise(LockHeld):
            show_runaway_processes(lockfile.strpath)

        lock.close()

        show_runaway_processes(lockfile.strpath)
Example #2
0
    def it_fails_when_there_are_locks(self, tmpdir):
        lockfile = tmpdir.ensure('lock')
        lock = lockfile.open()

        with ShouldRaise(LockHeld):
            show_runaway_processes(lockfile.strpath)

        lock.close()

        show_runaway_processes(lockfile.strpath)
Example #3
0
def clean_service(service_path):
    # we use SIGTERM; SIGKILL is cheating.
    limit = 100
    while limit > 0:  # pragma: no branch: we don't expect to ever hit the limit
        assert os.path.isdir(service_path), service_path
        try:
            show_runaway_processes(service_path)
            print('lock released -- done.')
            break
        except LockHeld:
            print('lock held -- killing!')
            for pid in fuser(service_path):
                try:
                    os.system('ps -fj %i' % pid)
                    os.kill(pid, signal.SIGTERM)
                except OSError as error:  # race condition -- process stopped between list and kill :pragma: no-cover
                    if error.errno == 3:  # no such process
                        pass
                    else:
                        raise
        limit -= 1
Example #4
0
def clean_service(service_path):
    # we use SIGTERM; SIGKILL is cheating.
    limit = 100
    while limit > 0:  # pragma: no branch: we don't expect to ever hit the limit
        assert os.path.isdir(service_path), service_path
        try:
            show_runaway_processes(service_path)
            print('lock released -- done.')
            break
        except LockHeld:
            print('lock held -- killing!')
            for pid in fuser(service_path):
                try:
                    os.system('ps -fj %i' % pid)
                    os.kill(pid, signal.SIGTERM)
                except OSError as error:  # race condition -- process stopped between list and kill :pragma: no-cover
                    if error.errno == 3:  # no such process
                        pass
                    else:
                        raise
        limit -= 1
Example #5
0
 def it_passes_when_there_are_no_locks(self, tmpdir):
     assert show_runaway_processes(tmpdir.strpath) is None
Example #6
0
 def it_passes_when_there_are_no_locks(self, tmpdir):
     assert show_runaway_processes(tmpdir.strpath) is None