Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
BoxuanXu
/
FlaskDriverMXNet2SeetaNet
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a72aa6a4
authored
Sep 09, 2017
by
BoxuanXu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix mysql bug
1 parent
b660959d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
20 deletions
src/Drive_Converter.py
src/mysql_glock.py
src/Drive_Converter.py
View file @
a72aa6a
...
@@ -42,8 +42,7 @@ output_layer = ""
...
@@ -42,8 +42,7 @@ output_layer = ""
pool_id
=
""
pool_id
=
""
err_msg
=
""
err_msg
=
""
post_url
=
"http://192.168l.1.127:1234/API"
post_url
=
"http://192.168.1.127:1234/API"
#post_url = "http://192.168.1.244:5000/result"
#init post info queue
#init post info queue
Info_Queue
=
Queue
.
Queue
()
Info_Queue
=
Queue
.
Queue
()
...
@@ -54,24 +53,31 @@ logging.basicConfig(
...
@@ -54,24 +53,31 @@ logging.basicConfig(
)
)
db_atlas
=
pymysql
.
connect
(
"192.168.1.127"
,
"defaultUser"
,
"magician"
,
"seetaAtlas"
,
3306
)
curl_atlas
=
db_atlas
.
cursor
()
curl_atlas_exe
=
db_atlas
.
cursor
()
db_l
=
Mysql_lock
()
lock_name
=
'db_queue'
def
get_path_from_db
(
modelid
,
seetanet_model
):
def
get_path_from_db
(
modelid
,
seetanet_model
):
#curl_atlas.execute("select path from seetaAtlas.model where id='%s'" % modelid)
#curl_atlas.execute("select path from seetaAtlas.model where id='%s'" % modelid)
ret
=
db_l
.
lock
(
lock_name
,
10
)
if
ret
!=
True
:
db_l
=
Mysql_lock
()
logging
.
info
(
"Can't get lock! exit!"
)
if
db_l
.
db
==
''
:
quit
()
return
None
,
None
#lock_name = 'db_queue'
#ret = db_l.lock(lock_name,10)
#if ret != True:
# logging.info("Can't get lock! exit!")
# quit()
ret
=
db_l
.
_execute
(
"select path from seetaAtlas.model where id='
%
s'"
%
modelid
)
ret
=
db_l
.
_execute
(
"select path from seetaAtlas.model where id='
%
s'"
%
modelid
)
if
ret
is
None
:
return
None
,
None
result_atlas
=
db_l
.
cursor
.
fetchall
()
result_atlas
=
db_l
.
cursor
.
fetchall
()
db_l
.
unlock
(
lock_name
)
#db_l.unlock(lock_name)
#if ret != True:
# logging.info("Can't release lock! exit!")
# quit()
if
len
(
result_atlas
)
!=
1
:
if
len
(
result_atlas
)
!=
1
:
...
@@ -275,8 +281,5 @@ if __name__ == '__main__':
...
@@ -275,8 +281,5 @@ if __name__ == '__main__':
t
.
start
();
t
.
start
();
app
.
run
(
host
=
'0.0.0.0'
)
app
.
run
(
host
=
'0.0.0.0'
)
finally
:
finally
:
curl_atlas_exe
.
close
()
curl_atlas
.
close
()
db_atlas
.
close
()
stbf_rls
()
stbf_rls
()
src/mysql_glock.py
View file @
a72aa6a
...
@@ -16,19 +16,22 @@ logging.basicConfig(
...
@@ -16,19 +16,22 @@ logging.basicConfig(
format
=
"[
%(asctime)
s]
%(name)
s:
%(levelname)
s:
%(message)
s"
format
=
"[
%(asctime)
s]
%(name)
s:
%(levelname)
s:
%(message)
s"
)
)
db_atlas
=
pymysql
.
connect
(
"192.168.1.127"
,
"defaultUser"
,
"magician"
,
"seetaAtlas"
,
3306
)
class
Mysql_lock
:
class
Mysql_lock
:
def
__init__
(
self
):
def
__init__
(
self
):
try
:
db_atlas
=
pymysql
.
connect
(
"192.168.1.127"
,
"defaultUser"
,
"magician"
,
"seetaAtlas"
,
3306
)
self
.
db
=
db_atlas
self
.
db
=
db_atlas
self
.
cursor
=
db_atlas
.
cursor
()
self
.
cursor
=
db_atlas
.
cursor
()
except
Exception
,
ex
:
logging
.
info
(
"Cannot connect to mysql server! Exception:
%
s"
,
str
(
ex
))
self
.
db
=
''
self
.
cursor
=
''
def
_execute
(
self
,
sql
):
def
_execute
(
self
,
sql
):
cursor
=
self
.
db
.
cursor
()
try
:
try
:
ret
=
self
.
cursor
.
execute
(
sql
)
ret
=
self
.
cursor
.
execute
(
sql
)
return
ret
return
ret
except
Exception
,
ex
:
except
Exception
,
ex
:
logging
.
info
(
"Execute sql
\"
%
s
\"
failed! Exception:
%
s"
,
sql
,
str
(
ex
))
logging
.
info
(
"Execute sql
\"
%
s
\"
failed! Exception:
%
s"
,
sql
,
str
(
ex
))
#cursor.close()
return
None
return
None
def
lock
(
self
,
lockstr
,
timeout
):
def
lock
(
self
,
lockstr
,
timeout
):
sql
=
"SELECT GET_LOCK('
%
s',
%
s)"
%
(
lockstr
,
timeout
)
sql
=
"SELECT GET_LOCK('
%
s',
%
s)"
%
(
lockstr
,
timeout
)
...
@@ -56,5 +59,10 @@ class Mysql_lock:
...
@@ -56,5 +59,10 @@ class Mysql_lock:
else
:
else
:
logging
.
info
(
"The lock '
%
s' did not exist."
,
lockstr
)
logging
.
info
(
"The lock '
%
s' did not exist."
,
lockstr
)
return
None
return
None
def
__del__
(
self
):
#Terminate the connection
if
self
.
cursor
!=
''
:
self
.
cursor
.
close
()
if
self
.
db
!=
''
:
self
.
db
.
close
()
Write
Preview
Markdown
is supported
Attach a file
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 post a comment