Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
Details
Activity
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
7e1d0f40
Commit
7e1d0f40
authored
Aug 25, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add multi-process
parent
650e2992
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
18 deletions
+24
-18
diaryQueueUpdate.py
diaryQueueUpdate.py
+24
-18
No files found.
diaryQueueUpdate.py
View file @
7e1d0f40
...
@@ -225,25 +225,31 @@ def pipe_line(queue_name, queue_arg, device_id):
...
@@ -225,25 +225,31 @@ def pipe_line(queue_name, queue_arg, device_id):
return
diary_queue
return
diary_queue
def
user_update
(
device_id
,
city_id
,
data_set_cid
):
def
user_update
(
device_id
,
city_id
,
queue_name
,
data_set_cid
):
queue_name_list
=
[
"native_queue"
,
"nearby_queue"
,
"nation_queue"
,
"megacity_queue"
]
queue_list
=
get_queue
(
device_id
,
city_id
,
queue_name
)
for
queue_name
in
queue_name_list
:
if
queue_list
:
queue_list
=
get_queue
(
device_id
,
city_id
,
queue_name
)
queue_predict
=
list
(
set
(
queue_list
)
&
set
(
data_set_cid
))
if
queue_list
:
queue_not_predict
=
list
(
set
(
queue_list
)
-
set
(
data_set_cid
))
queue_predict
=
list
(
set
(
queue_list
)
&
set
(
data_set_cid
))
queue_arg
=
[
queue_predict
,
queue_not_predict
,
queue_list
]
queue_not_predict
=
list
(
set
(
queue_list
)
-
set
(
data_set_cid
))
if
queue_predict
!=
[]:
queue_arg
=
[
queue_predict
,
queue_not_predict
,
queue_list
]
diary_queue
=
pipe_line
(
queue_name
,
queue_arg
,
device_id
)
if
queue_predict
!=
[]:
if
diary_queue
:
diary_queue
=
pipe_line
(
queue_name
,
queue_arg
,
device_id
)
update_sql_dairy_queue
(
queue_name
,
diary_queue
,
device_id
,
city_id
)
if
diary_queue
:
print
(
"更新结束"
)
update_sql_dairy_queue
(
queue_name
,
diary_queue
,
device_id
,
city_id
)
print
(
"更新结束"
)
else
:
print
(
"获取的日记列表是空,所以不更新日记队列"
)
else
:
else
:
print
(
"
预测集是空,不需要预测
"
)
print
(
"
获取的日记列表是空,所以不更新日记队列
"
)
else
:
else
:
print
(
"日记队列为空"
)
print
(
"预测集是空,不需要预测"
)
else
:
print
(
"日记队列为空"
)
def
mult_iproecess_update
(
device_id
,
city_id
,
data_set_cid
):
queue_name_list
=
[
"native_queue"
,
"nearby_queue"
,
"nation_queue"
,
"megacity_queue"
]
pool
=
Pool
(
4
)
for
queue_name
in
queue_name_list
:
pool
.
apply_async
(
user_update
,
(
device_id
,
city_id
,
queue_name
,
data_set_cid
,))
pool
.
close
()
pool
.
join
()
def
run
():
def
run
():
...
@@ -252,7 +258,7 @@ def run():
...
@@ -252,7 +258,7 @@ def run():
for
device_city
in
device_city_list
:
for
device_city
in
device_city_list
:
start
=
time
.
time
()
start
=
time
.
time
()
user_update
(
device_city
[
0
],
device_city
[
1
],
data_set_cid
)
mult_iproecess_update
(
device_city
[
0
],
device_city
[
1
],
data_set_cid
)
end
=
time
.
time
()
end
=
time
.
time
()
print
(
"更新该用户队列耗时{}秒"
.
format
((
end
-
start
)))
print
(
"更新该用户队列耗时{}秒"
.
format
((
end
-
start
)))
print
(
"end"
)
print
(
"end"
)
...
...
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