mirror of
https://github.com/newnius/YAO-agent.git
synced 2025-06-06 05:21:55 +00:00
retry when creating dir failed
This commit is contained in:
parent
6b7b1221a9
commit
86c1ba01c6
23
agent.py
23
agent.py
@ -299,14 +299,21 @@ class MyHandler(BaseHTTPRequestHandler):
|
||||
token = generate_token(16)
|
||||
|
||||
if len(dfs_src) > 0:
|
||||
try:
|
||||
# Docker wouldn't create dir by default on bind mode,
|
||||
# see https://github.com/moby/moby/issues/13121
|
||||
path = Path(dfs_src)
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
except OSError as e:
|
||||
print("Creation of the directory %s failed" % dfs_src)
|
||||
print(traceback.format_exc())
|
||||
failed_cnt = 0
|
||||
while True:
|
||||
failed_cnt += 1
|
||||
if failed_cnt > 3:
|
||||
break
|
||||
try:
|
||||
# Docker wouldn't create dir by default on bind mode,
|
||||
# see https://github.com/moby/moby/issues/13121
|
||||
path = Path(dfs_src)
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
break
|
||||
except OSError as e:
|
||||
print("Creation of the directory %s failed" % dfs_src)
|
||||
print(e)
|
||||
print(traceback.format_exc())
|
||||
|
||||
try:
|
||||
# set PYTHONUNBUFFERED=1 to output immediately
|
||||
|
Loading…
Reference in New Issue
Block a user