Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cloud-infrastructure
data-analytics
Commits
5c7cfb2e
Commit
5c7cfb2e
authored
Apr 27, 2021
by
Antonin Dvorak
Committed by
Domenico Giordano
Apr 28, 2021
Browse files
sqlite3 - retry also for execute part
parent
847218f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
adcern/sqlite3_backend.py
View file @
5c7cfb2e
import
sqlite3
import
sqlite3
def
modify_db
(
conn
,
query
,
...
...
@@ -16,12 +17,20 @@ def modify_db(conn,
args: array
additional arguments for execute query, optional
"""
with
conn
.
cursor
()
as
c
:
if
args
:
c
.
execute
(
query
,
args
)
else
:
c
.
execute
(
query
)
with
conn
.
cursor
()
as
c
:
for
x
in
range
(
0
,
10
):
try
:
if
args
:
c
.
execute
(
query
,
args
)
else
:
c
.
execute
(
query
)
except
:
print
(
"Sqlite3 execute unsuccessful, retrying...."
)
time
.
sleep
(
1
)
pass
finally
:
break
# retry commit - db might be locked by different process
for
x
in
range
(
0
,
10
):
...
...
@@ -32,5 +41,4 @@ def modify_db(conn,
time
.
sleep
(
1
)
pass
finally
:
break
\ No newline at end of file
break
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment