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
9698e4f8
Commit
9698e4f8
authored
Jan 09, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改coco,解决退出有时延的问题
parent
0ad0a272
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
10 deletions
+7
-10
app.py
coco/app.py
+7
-8
session.py
coco/session.py
+0
-2
No files found.
coco/app.py
View file @
9698e4f8
...
...
@@ -125,6 +125,10 @@ class Coco:
else
:
return
True
def
heartbeat_async
(
self
):
t
=
threading
.
Thread
(
target
=
self
.
heartbeat
)
t
.
start
()
def
handle_task
(
self
,
tasks
):
for
task
in
tasks
:
self
.
task_handler
.
handle
(
task
)
...
...
@@ -212,15 +216,10 @@ class Coco:
def
add_session
(
self
,
session
):
with
self
.
lock
:
self
.
sessions
.
append
(
session
)
self
.
heartbeat
()
self
.
heartbeat
_async
()
def
remove_session
(
self
,
session
):
with
self
.
lock
:
logger
.
info
(
"Remove session: {}"
.
format
(
session
))
for
i
in
range
(
10
):
if
self
.
heartbeat
():
self
.
sessions
.
remove
(
session
)
break
else
:
time
.
sleep
(
1
)
self
.
sessions
.
remove
(
session
)
self
.
heartbeat_async
()
coco/session.py
View file @
9698e4f8
...
...
@@ -126,8 +126,6 @@ class Session:
if
len
(
data
)
==
0
:
msg
=
"Server close the connection"
logger
.
info
(
msg
)
for
watcher
in
[
self
.
client
]
+
self
.
_watchers
+
self
.
_sharers
:
watcher
.
send
(
msg
.
encode
(
'utf-8'
))
self
.
close
()
break
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