def WaitForFileServerToStart(port):
"""
Wait for the Flask file server to start up. Test it by trying the
PyUpdater update URL, e.g. http://127.0.0.1:12345. If we receive
a ConnectionError, we continue waiting, but if we receive an HTTP
response code (404), we return True. For a frozen app, e.g. a
Mac .app bundle, the location of the updates must be supplied by
an environment variable, whereas when running from the source repo,
the location of the updates is likely to be ./pyu-data/deploy/
"""
url = 'http://%s:%s/fileserver-is-ready' % (LOCALHOST, port)
attempts = 0
while True:
try:
attempts += 1
requests.get(url, timeout=1)
return True
except requests.exceptions.ConnectionError:
time.sleep(0.25)
if attempts > 10:
logger.warning("WaitForFileServerToStart: timeout")
return
评论列表
文章目录