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
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
ebf2f00e
Commit
ebf2f00e
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Add example for client management
parent
3ccae085
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/corpora/events.py
+11
-9
11 additions, 9 deletions
app/corpora/events.py
with
11 additions
and
9 deletions
app/corpora/events.py
+
11
−
9
View file @
ebf2f00e
...
...
@@ -8,12 +8,14 @@ import logging
import
time
analysis_clients
=
{}
@socketio.on
(
'
init_corpus_analysis
'
)
@login_required
def
init_corpus_analysis
(
corpus_id
):
logger
=
logging
.
getLogger
(
__name__
)
logger
.
warning
(
'
init_corpus_analysis
'
)
'''
TODO: Check if current_user is allowed to subscribe to this
'''
time
.
sleep
(
5
)
# wait for IP of container only for dev
socketio
.
start_background_task
(
observe_corpus_analysis_connection
,
current_app
.
_get_current_object
(),
corpus_id
,
...
...
@@ -24,20 +26,20 @@ def init_corpus_analysis(corpus_id):
def
recv_query
(
message
):
logger
=
logging
.
getLogger
(
__name__
)
logger
.
warning
(
message
)
analysis_client
=
analysis_clients
[
request
.
sid
]
def
observe_corpus_analysis_connection
(
app
,
corpus_id
,
session_id
):
logger
=
logging
.
getLogger
(
__name__
)
with
app
.
app_context
():
time
.
sleep
(
5
)
# wait for IP of container only for dev
corpus
=
Corpus
.
query
.
filter_by
(
id
=
corpus_id
).
first
()
logger
.
warning
(
'
IP adress is: {}
'
.
format
(
corpus
.
analysis_container_ip
))
cqi_client
=
CQiClient
(
host
=
corpus
.
analysis_container_ip
)
cqi_client
.
ctrl_connect
(
'
opaque
'
,
'
opaque
'
)
logger
.
warning
(
'
MÖÖÖÖP
'
)
analysis_client
=
CQiClient
(
host
=
corpus
.
analysis_container_ip
)
analysis_client
.
ctrl_connect
(
'
opaque
'
,
'
opaque
'
)
analysis_clients
[
session_id
]
=
analysis_client
while
session_id
in
connected_sessions
:
logger
.
warning
(
cqi_client
.
ctrl_ping
())
logger
.
warning
(
'
Run container, run!
'
)
logger
.
warning
(
analysis_client
.
ctrl_ping
())
socketio
.
sleep
(
3
)
analysis_client
.
ctrl_bye
()
corpus
.
status
=
'
stop analysis
'
db
.
session
.
commit
()
logger
.
warning
(
'
Stop container, stop!
'
)
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