示例#1
0
def clean_service(service_path):
    # we use SIGTERM; SIGKILL is cheating.
    print('killing.')
    limit = 100
    while limit > 0:  # pragma: no cover: we don't expect to ever hit the limit
        try:
            check_lock(service_path)
            break
        except LockHeld:
            for pid in lsof(service_path):
                try:
                    os.kill(pid, 10)
                except OSError as error:
                    if error.errno == 3:  # no such process
                        pass
                    else:
                        raise
            limit -= 1
示例#2
0
def clean_service(service_path):
    # we use SIGTERM; SIGKILL is cheating.
    print('killing.')
    limit = 100
    while limit > 0:  # pragma: no cover: we don't expect to ever hit the limit
        try:
            check_lock(service_path)
            break
        except LockHeld:
            for pid in lsof(service_path):
                try:
                    os.kill(pid, 10)
                except OSError as error:
                    if error.errno == 3:  # no such process
                        pass
                    else:
                        raise
            limit -= 1
示例#3
0
 def it_passes_when_there_are_no_locks(self, tmpdir):
     assert check_lock(tmpdir.strpath) is None
示例#4
0
 def it_fails_when_there_are_locks(self, tmpdir):
     with tmpdir.as_cwd():
         with ShouldRaise(LockHeld):
             check_lock(tmpdir.strpath)
示例#5
0
 def it_passes_when_there_are_no_locks(self, tmpdir):
     assert check_lock(tmpdir.strpath) is None
示例#6
0
 def it_fails_when_there_are_locks(self, tmpdir):
     with tmpdir.as_cwd():
         with ShouldRaise(LockHeld):
             check_lock(tmpdir.strpath)