mirror of
https://github.com/newnius/YAO-agent.git
synced 2025-06-06 21:31: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)
|
token = generate_token(16)
|
||||||
|
|
||||||
if len(dfs_src) > 0:
|
if len(dfs_src) > 0:
|
||||||
try:
|
failed_cnt = 0
|
||||||
# Docker wouldn't create dir by default on bind mode,
|
while True:
|
||||||
# see https://github.com/moby/moby/issues/13121
|
failed_cnt += 1
|
||||||
path = Path(dfs_src)
|
if failed_cnt > 3:
|
||||||
path.mkdir(parents=True, exist_ok=True)
|
break
|
||||||
except OSError as e:
|
try:
|
||||||
print("Creation of the directory %s failed" % dfs_src)
|
# Docker wouldn't create dir by default on bind mode,
|
||||||
print(traceback.format_exc())
|
# 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:
|
try:
|
||||||
# set PYTHONUNBUFFERED=1 to output immediately
|
# set PYTHONUNBUFFERED=1 to output immediately
|
||||||
|
Loading…
Reference in New Issue
Block a user