How to use the pgctl.functions.show_runaway_processes function in pgctl

To help you get started, we’ve selected a few pgctl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Yelp / pgctl / tests / spec / dirty_tests.py View on Github external
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
github Yelp / pgctl / tests / unit / functions.py View on Github external
def it_passes_when_there_are_no_locks(self, tmpdir):
        assert show_runaway_processes(tmpdir.strpath) is None
github Yelp / pgctl / tests / unit / functions.py View on Github external
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)
github Yelp / pgctl / pgctl / service.py View on Github external
def handle_race(path):
        show_runaway_processes(path)
        if handle_race.limit > 0:
            handle_race.limit -= 1
        else:
            reraise(Impossible('lock is held, but not by any process, ten times'))
    handle_race.limit = 10