Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
e658d2bb
Commit
e658d2bb
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Don't create new app instance for background tasks. Reuse the old one!
parent
565d273d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/__init__.py
+1
-5
1 addition, 5 deletions
app/__init__.py
app/main/events.py
+4
-9
4 additions, 9 deletions
app/main/events.py
with
5 additions
and
14 deletions
app/__init__.py
+
1
−
5
View file @
e658d2bb
...
...
@@ -13,16 +13,12 @@ mail = Mail()
socketio
=
SocketIO
()
def
create_app
(
config_name
,
main
=
True
):
def
create_app
(
config_name
):
app
=
Flask
(
__name__
)
app
.
config
.
from_object
(
config
[
config_name
])
config
[
config_name
].
init_app
(
app
)
db
.
init_app
(
app
)
if
not
main
:
return
app
login_manager
.
init_app
(
app
)
mail
.
init_app
(
app
)
socketio
.
init_app
(
app
,
message_qeue
=
'
redis://
'
)
...
...
This diff is collapsed.
Click to expand it.
app/main/events.py
+
4
−
9
View file @
e658d2bb
from
flask
import
request
from
flask
import
current_app
,
request
from
flask_login
import
current_user
,
login_required
from
..
import
create_app
,
db
,
socketio
from
..
import
db
,
socketio
from
..models
import
User
import
json
import
jsonpatch
...
...
@@ -23,6 +23,7 @@ def connect():
'
task associated with the sid.
'''
socketio
.
start_background_task
(
background_task
,
current_app
.
_get_current_object
(),
current_user
.
id
,
request
.
sid
)
...
...
@@ -37,7 +38,7 @@ def disconnect():
disconnected
.
append
(
request
.
sid
)
def
background_task
(
user_id
,
session_id
):
def
background_task
(
app
,
user_id
,
session_id
):
'''
'
Sends initial corpus and job lists to the client. Afterwards it checks
'
every 3 seconds if changes to the initial values appeared. If changes are
...
...
@@ -48,12 +49,6 @@ def background_task(user_id, session_id):
'
'
> where
'
*
'
is either
'
corpora
'
or
'
jobs
'
'''
'''
'
Create an app instance to get access to an app_context with which db
'
operations are fulfilled.
'''
app
=
create_app
(
os
.
getenv
(
'
FLASK_CONFIG
'
)
or
'
default
'
,
main
=
False
)
with
app
.
app_context
():
user
=
db
.
session
.
query
(
User
).
filter_by
(
id
=
user_id
).
first
()
'''
Get current values from the database.
'''
...
...
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