Skip to content

Commit

Permalink
added wait time for DB connection attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
JarryShaw committed Jan 20, 2024
1 parent 8c9afa3 commit 56c536c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions darc/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import contextlib
import os
import sys
import time
import traceback
from typing import TYPE_CHECKING

from darc.const import DB, DB_WEB, DEBUG, FLAG_DB, PATH_ID, PATH_LN
from darc.const import DARC_WAIT, DB, DB_WEB, DEBUG, FLAG_DB, PATH_ID, PATH_LN
from darc.db import _db_operation, _redis_command, save_requests
from darc.error import DatabaseOperaionFailed
from darc.link import parse_link
Expand Down Expand Up @@ -110,6 +111,9 @@ def main(argv: 'Optional[List[str]]' = None) -> int:
except Exception:
logger.pexc(LOG_WARNING, category=DatabaseOperaionFailed,
line='DB.create_tables([HostnameQueueModel, ...]')

# wait for DB to start
time.sleep(DARC_WAIT) # type: ignore[arg-type]
continue
break

Expand All @@ -125,6 +129,9 @@ def main(argv: 'Optional[List[str]]' = None) -> int:
except Exception:
logger.pexc(LOG_WARNING, category=DatabaseOperaionFailed,
line='DB.create_tables([HostnameModel, ...]')

# wait for DB to start
time.sleep(DARC_WAIT) # type: ignore[arg-type]
continue
break

Expand All @@ -136,7 +143,7 @@ def main(argv: 'Optional[List[str]]' = None) -> int:
_redis_command('delete', 'queue_selenium')

link_list = []
for link in filter(None, map(lambda s: s.strip(), args.link)): # type: ignore[name-defined,var-annotated]
for link in filter(None, map(lambda s: s.strip(), args.link)): # type: ignore[var-annotated]
logger.pline(LOG_DEBUG, link)
link_list.append(link)

Expand Down

0 comments on commit 56c536c

Please sign in to comment.