Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mffzoom
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wizards
mffzoom
Commits
2387761f
Commit
2387761f
authored
5 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Hook: Reset DB transaction at the end of each request
parent
f4e51085
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
hook/hook.wsgi
+11
-0
11 additions, 0 deletions
hook/hook.wsgi
with
11 additions
and
0 deletions
hook/hook.wsgi
+
11
−
0
View file @
2387761f
...
@@ -38,6 +38,15 @@ def db_query(query, args=()):
...
@@ -38,6 +38,15 @@ def db_query(query, args=()):
db_connect
()
db_connect
()
db
.
execute
(
query
,
args
)
db
.
execute
(
query
,
args
)
def
db_reset
():
# At the end of every request, we have to close the implicitly opened
# transaction. Otherwise we end up with serving stale data.
if
db_connection
is
not
None
:
try
:
db_connection
.
rollback
()
except
:
pass
### Utilities ###
### Utilities ###
def
parse_time
(
iso_time
):
def
parse_time
(
iso_time
):
...
@@ -279,3 +288,5 @@ def application(env, start_response):
...
@@ -279,3 +288,5 @@ def application(env, start_response):
except
Exception
as
exc
:
except
Exception
as
exc
:
app
.
log
(
traceback
.
print_exception
(
etype
=
None
,
value
=
exc
,
tb
=
exc
.
__traceback__
))
app
.
log
(
traceback
.
print_exception
(
etype
=
None
,
value
=
exc
,
tb
=
exc
.
__traceback__
))
return
app
.
http_error
(
500
,
"
Internal server error
"
)
return
app
.
http_error
(
500
,
"
Internal server error
"
)
finally
:
db_reset
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment