Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
jumpserver
Commits
43c07707
Commit
43c07707
authored
Nov 06, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
使用原生select
parent
01d6f751
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
run_websocket.py
run_websocket.py
+14
-11
No files found.
run_websocket.py
View file @
43c07707
...
...
@@ -21,7 +21,8 @@ from pyinotify import WatchManager, Notifier, ProcessEvent, IN_DELETE, IN_CREATE
# from gevent import monkey
# monkey.patch_all()
# import gevent
from
gevent.socket
import
wait_read
,
wait_write
# from gevent.socket import wait_read, wait_write
import
struct
,
fcntl
,
signal
,
socket
,
select
,
fnmatch
import
paramiko
...
...
@@ -200,16 +201,18 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
try
:
data
=
''
while
True
:
wait_read
(
self
.
chan
.
fileno
())
recv
=
self
.
chan
.
recv
(
1024
)
if
not
len
(
recv
):
return
data
+=
recv
try
:
self
.
write_message
(
json
.
dumps
({
'data'
:
data
}))
data
=
''
except
UnicodeDecodeError
:
pass
r
,
w
,
e
=
select
.
select
([
self
.
chan
,
sys
.
stdin
],
[],
[])
if
self
.
chan
in
r
:
recv
=
self
.
chan
.
recv
(
1024
)
print
recv
if
not
len
(
recv
):
return
data
+=
recv
try
:
self
.
write_message
(
json
.
dumps
({
'data'
:
data
}))
data
=
''
except
UnicodeDecodeError
:
pass
finally
:
self
.
close
()
...
...
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