Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
adc2018-system
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
adc2018
adc2018-system
Commits
a350ed9a
Commit
a350ed9a
authored
Aug 14, 2018
by
Kento HASEGAWA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use req_id to identify the processing question
parent
fa33ab65
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
13 deletions
+16
-13
main.py
comm/server/main.py
+16
-13
No files found.
comm/server/main.py
View file @
a350ed9a
...
...
@@ -59,6 +59,7 @@ def load_questions():
"queue"
:
Queue
(),
"board_size"
:
board_size
,
"line_num"
:
line_num
,
"last_req"
:
None
,
"answers"
:
[],
}
...
...
@@ -112,18 +113,17 @@ def post():
global
questions
global
app_args
_client
=
request
.
form
[
"client"
]
_qname
=
request
.
form
[
"qname"
]
_answer
=
request
.
form
[
"answer"
]
_cputime
=
request
.
form
[
"cputime"
]
receive_time
=
datetime
.
datetime
.
now
()
receive_time_str
=
receive_time
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
dat
=
{
"client"
:
_client
,
"req_id"
:
request
.
form
[
'req_id'
],
"client"
:
request
.
form
[
'client'
],
"answer"
:
_answer
,
"cputime"
:
_cputime
,
"cputime"
:
request
.
form
[
'cputime'
]
,
"timestamp"
:
receive_time
.
strftime
(
"
%
Y/
%
m/
%
d
%
H:
%
M:
%
S"
)
}
...
...
@@ -218,23 +218,26 @@ def solve_questions(qname, qstr):
global
clients
global
questions
global
current_seed
global
app_args
def
worker
(
host
,
qname
,
qstr
,
qseed
,
req
uest_time
):
def
worker
(
host
,
qname
,
qstr
,
qseed
,
req
_id
):
_url
=
"http://{}/start"
.
format
(
host
)
try
:
r
=
requests
.
post
(
_url
,
data
=
{
"client"
:
host
,
"qname"
:
qname
,
"question"
:
qstr
,
"qseed"
:
qseed
,
"req
uest_time"
:
request_time
})
r
=
requests
.
post
(
_url
,
data
=
{
"client"
:
host
,
"qname"
:
qname
,
"question"
:
qstr
,
"qseed"
:
qseed
,
"req
_id"
:
req_id
})
client_res
=
json
.
loads
(
r
.
text
)
except
Exception
as
e
:
sys
.
stderr
.
write
(
str
(
e
)
+
"
\n
"
)
threads
=
[]
request_time
=
time
.
time
()
# 時刻をリクエストIDとして設定
req_id
=
time
.
time
()
questions
[
qname
][
'last_req'
]
=
req_id
for
c
in
clients
:
# 問題はSolverに送る
if
c
[
1
]
==
'Solver'
:
client_addr
=
c
[
0
]
_th
=
threading
.
Thread
(
name
=
client_addr
,
target
=
worker
,
args
=
(
client_addr
,
qname
,
qstr
,
current_seed
,
request_time
))
_th
=
threading
.
Thread
(
name
=
client_addr
,
target
=
worker
,
args
=
(
client_addr
,
qname
,
qstr
,
current_seed
,
req_id
))
_th
.
start
()
threads
.
append
(
_th
)
current_seed
+=
1
...
...
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