Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
coco
Commits
e1a6e75b
Commit
e1a6e75b
authored
Jan 10, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
[Merge] with dev
parents
a132613b
9698e4f8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
11 deletions
+7
-11
app.py
coco/app.py
+6
-7
interactive.py
coco/interactive.py
+1
-2
session.py
coco/session.py
+0
-2
No files found.
coco/app.py
View file @
e1a6e75b
...
@@ -125,6 +125,10 @@ class Coco:
...
@@ -125,6 +125,10 @@ class Coco:
else
:
else
:
return
True
return
True
def
heartbeat_async
(
self
):
t
=
threading
.
Thread
(
target
=
self
.
heartbeat
)
t
.
start
()
def
handle_task
(
self
,
tasks
):
def
handle_task
(
self
,
tasks
):
for
task
in
tasks
:
for
task
in
tasks
:
self
.
task_handler
.
handle
(
task
)
self
.
task_handler
.
handle
(
task
)
...
@@ -212,15 +216,10 @@ class Coco:
...
@@ -212,15 +216,10 @@ class Coco:
def
add_session
(
self
,
session
):
def
add_session
(
self
,
session
):
with
self
.
lock
:
with
self
.
lock
:
self
.
sessions
.
append
(
session
)
self
.
sessions
.
append
(
session
)
self
.
heartbeat
()
self
.
heartbeat
_async
()
def
remove_session
(
self
,
session
):
def
remove_session
(
self
,
session
):
with
self
.
lock
:
with
self
.
lock
:
logger
.
info
(
"Remove session: {}"
.
format
(
session
))
logger
.
info
(
"Remove session: {}"
.
format
(
session
))
for
i
in
range
(
10
):
if
self
.
heartbeat
():
self
.
sessions
.
remove
(
session
)
self
.
sessions
.
remove
(
session
)
break
self
.
heartbeat_async
()
else
:
time
.
sleep
(
1
)
coco/interactive.py
View file @
e1a6e75b
...
@@ -134,8 +134,7 @@ class InteractiveServer:
...
@@ -134,8 +134,7 @@ class InteractiveServer:
if
q
==
''
:
if
q
==
''
:
result
=
self
.
assets
result
=
self
.
assets
# 用户输入的是数字,可能想使用id唯一键搜索
# 用户输入的是数字,可能想使用id唯一键搜索
elif
q
.
isdigit
():
elif
q
.
isdigit
()
and
self
.
search_result
and
len
(
self
.
search_result
)
>=
int
(
q
):
if
len
(
self
.
search_result
)
>=
int
(
q
):
result
=
[
self
.
search_result
[
int
(
q
)
-
1
]]
result
=
[
self
.
search_result
[
int
(
q
)
-
1
]]
# 全匹配到则直接返回全匹配的
# 全匹配到则直接返回全匹配的
...
...
coco/session.py
View file @
e1a6e75b
...
@@ -126,8 +126,6 @@ class Session:
...
@@ -126,8 +126,6 @@ class Session:
if
len
(
data
)
==
0
:
if
len
(
data
)
==
0
:
msg
=
"Server close the connection"
msg
=
"Server close the connection"
logger
.
info
(
msg
)
logger
.
info
(
msg
)
for
watcher
in
[
self
.
client
]
+
self
.
_watchers
+
self
.
_sharers
:
watcher
.
send
(
msg
.
encode
(
'utf-8'
))
self
.
close
()
self
.
close
()
break
break
for
watcher
in
[
self
.
client
]
+
self
.
_watchers
+
self
.
_sharers
:
for
watcher
in
[
self
.
client
]
+
self
.
_watchers
+
self
.
_sharers
:
...
...
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