Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
adc2019-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
adc2019
adc2019-system
Commits
105e3566
Commit
105e3566
authored
Jul 24, 2019
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the stop button that will stop all working solvers (but currently does not work)
parent
c2566bbc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
5 deletions
+34
-5
host.py
roles/host.py
+6
-0
solver.py
roles/solver.py
+7
-3
adc2019.js
static/js/adc2019.js
+20
-1
part_problem_status.html
templates/part_problem_status.html
+1
-1
No files found.
roles/host.py
View file @
105e3566
...
...
@@ -125,6 +125,9 @@ class Host(object):
elif
cmd
==
'request/status'
:
request_id
=
float
(
params
[
'request_id'
])
return
self
.
get_request_status
(
request_id
)
elif
cmd
==
'stop'
:
self
.
worker_manager
.
request_stop
()
return
{}
elif
cmd
==
'view/solution'
:
problem_key
=
params
[
'problem'
]
solution_id
=
params
[
'solution'
]
...
...
@@ -150,6 +153,9 @@ class WorkerManager(object):
def
get_workers
(
self
):
return
self
.
workers
def
request_stop
(
self
):
self
.
broadcast
(
'stop'
,
{})
def
broadcast
(
self
,
cmd
,
params
):
threads
=
[]
...
...
roles/solver.py
View file @
105e3566
...
...
@@ -12,7 +12,7 @@ class StoppableThread(threading.Thread):
super
(
StoppableThread
,
self
)
.
__init__
(
target
=
target
,
args
=
args
)
self
.
_status
=
'running'
def
stop
(
self
):
if
self
.
_status
==
'running'
:
if
self
.
is_running
()
:
self
.
_status
=
'stopping'
def
stopped
(
self
):
self
.
_status
=
'stopped'
...
...
@@ -80,18 +80,22 @@ class Solver(object):
else
:
return
{
'status'
:
'busy'
}
def
stop_solver
():
def
stop_solver
(
self
):
if
self
.
thread
is
not
None
:
if
self
.
thread
.
is_running
():
self
.
thread
.
stop
()
self
.
thread
.
join
()
self
.
thread
.
join
(
0.1
)
self
.
thread
=
None
return
{
'status'
:
'stopped'
}
def
call_api
(
self
,
method
,
cmd
,
params
):
if
cmd
==
'role'
:
return
{
'role'
:
self
.
type
}
elif
cmd
==
'solve'
:
return
self
.
start_solver
(
params
)
elif
cmd
==
'stop'
:
return
self
.
stop_solver
()
else
:
return
None
static/js/adc2019.js
View file @
105e3566
...
...
@@ -49,7 +49,6 @@ class StatusView {
}),
contentType
:
'application/json'
}).
done
((
d
)
=>
{
// TODO: タイムアウトになる時間まで,モーダル表示させる
var
request_id
=
d
[
'request_id'
];
var
timeout
=
d
[
'timeout'
];
...
...
@@ -62,10 +61,28 @@ class StatusView {
// console.log(e);
_this
.
show_problem
();
})
_this
.
container
.
find
(
'.stop-button'
).
click
(()
=>
{
_this
.
stop_solver
();
});
_this
.
get_request_status
(
request_id
,
timeout
);
});
}
// 強制停止
stop_solver
(){
var
_this
=
this
;
$
.
ajax
({
type
:
"GET"
,
dataType
:
"json"
,
url
:
"/api/stop"
,
}).
done
((
d
)
=>
{
_this
.
request_refresh_timer
=
'stopped'
;
alert
(
d
);
});
}
get_request_status
(
request_id
,
timeout
){
var
_this
=
this
;
...
...
@@ -81,6 +98,8 @@ class StatusView {
// console.log(status);
if
(
status
==
'done'
){
_this
.
request_refresh_timer
=
null
;
}
else
if
(
_this
.
request_refresh_timer
==
'stopped'
){
_this
.
request_refresh_timer
=
null
;
}
else
{
_this
.
request_refresh_timer
=
setTimeout
(
_this
.
get_request_status
(
request_id
,
timeout
),
1000
);
}
...
...
templates/part_problem_status.html
View file @
105e3566
...
...
@@ -55,7 +55,7 @@
処理中...
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-danger"
>
Stop
</button>
<button
type=
"button"
class=
"btn btn-danger
stop-button
"
>
Stop
</button>
<button
type=
"button"
class=
"btn btn-primary"
data-dismiss=
"modal"
>
Close
</button>
</div>
</div>
...
...
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