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
5b36cb84
Commit
5b36cb84
authored
Aug 09, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify add_data_to_redis,change main for test
parent
b1a057d2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
29 deletions
+17
-29
predictDiary.py
predictDiary.py
+13
-12
utils.py
utils.py
+4
-17
No files found.
predictDiary.py
View file @
5b36cb84
...
@@ -90,16 +90,17 @@ def router(device_id):
...
@@ -90,16 +90,17 @@ def router(device_id):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
# TODO 如果耗时小于一分钟,下一次取到的device_id和上一次相同
# TODO 如果耗时小于一分钟,下一次取到的device_id和上一次相同
while
True
:
router
(
'358035085192742'
)
start
=
time
.
time
()
# while True:
empty
,
device_id_list
=
get_active_users
()
# start = time.time()
if
empty
:
# empty,device_id_list = get_active_users()
time
.
sleep
(
10
)
# if empty:
else
:
# time.sleep(10)
for
device_id
in
device_id_list
:
# else:
router
(
device_id
)
# for device_id in device_id_list:
# router(device_id)
end
=
time
.
time
()
#
time_cost
=
(
end
-
start
)
# end = time.time()
print
(
"预测耗时{}秒"
.
format
(
time_cost
))
# time_cost = (end - start)
# print("预测耗时{}秒".format(time_cost))
utils.py
View file @
5b36cb84
...
@@ -15,25 +15,12 @@ def con_sql(sql):
...
@@ -15,25 +15,12 @@ def con_sql(sql):
db
.
close
()
db
.
close
()
return
df
return
df
class
Database
:
def
__init__
(
self
):
self
.
host
=
'10.30.50.58'
self
.
port
=
6379
self
.
db
=
12
self
.
write_pool
=
{}
def
add_write
(
self
,
key
,
val
):
self
.
write_pool
[
key
]
=
val
def
batch_write
(
self
):
r
=
redis
.
StrictRedis
(
host
=
self
.
host
,
port
=
self
.
port
,
db
=
self
.
db
)
r
.
mset
(
self
.
write_pool
)
# 把数据写到redis里
# 把数据写到redis里
def
add_data_to_redis
(
key
,
val
):
def
add_data_to_redis
(
key
,
val
):
db
=
Database
()
r
=
redis
.
StrictRedis
(
host
=
'10.30.50.58'
,
port
=
6379
,
db
=
12
)
db
.
add_write
(
key
,
val
)
r
.
set
(
key
,
val
)
db
.
batch_write
()
# 设置key的过期时间
r
.
expire
(
key
,
36
*
60
)
# ffm 格式转换函数、类
# ffm 格式转换函数、类
...
...
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