-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Yuuzi261/develope
0.3.4
- Loading branch information
Showing
6 changed files
with
75 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import sqlite3 | ||
from time import sleep | ||
from random import randint | ||
|
||
from src.log import setup_logger | ||
|
||
log = setup_logger(__name__) | ||
|
||
def execute(conn: sqlite3.Connection, sql_statement: str, param: tuple, task_name: str = 'unknown'): | ||
cursor = conn.cursor() | ||
for retry in range(5): | ||
try: | ||
cursor.execute(sql_statement, param) | ||
conn.commit() | ||
except: | ||
waiting = randint(1, 5) | ||
log.info(f'in task {task_name}: the database is locked, try again in {waiting} seconds, number of retries: {retry}') | ||
sleep(waiting) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters