Onionr/onionr/onionrutils/checkcommunicator.py
2019-06-23 12:41:07 -05:00

19 lines
523 B
Python

import time, os
def is_communicator_running(core_inst, timeout = 5, interval = 0.1):
try:
runcheck_file = core_inst.dataDir + '.runcheck'
if not os.path.isfile(runcheck_file):
open(runcheck_file, 'w+').close()
starttime = time.time()
while True:
time.sleep(interval)
if not os.path.isfile(runcheck_file):
return True
elif time.time() - starttime >= timeout:
return False
except:
return False