def tearDownClass(cls):
     try:
         conns = net_connections()
         pid = [
             x.pid for x in conns if x.status == 'LISTEN'
             and x.laddr[1] == 47334 and x.pid is not None
         ]
         if len(pid) > 0:
             os.kill(pid[0], 9)
     except Exception:
         pass
Exemple #2
0
def stop_mindsdb(sp=None):
    if sp:
        sp.kill()
    conns = net_connections()
    pids = [
        x.pid for x in conns
        if x.pid is not None and x.status in ['LISTEN', 'CLOSE_WAIT']
        and x.laddr[1] in (47334, 47335, 47336)
    ]

    for pid in pids:
        try:
            os.kill(pid, 9)
        # process may be killed by OS due to some reasons in that moment
        except ProcessLookupError:
            pass