Commit 43c07707 authored by ibuler's avatar ibuler

使用原生select

parent 01d6f751
...@@ -21,7 +21,8 @@ from pyinotify import WatchManager, Notifier, ProcessEvent, IN_DELETE, IN_CREATE ...@@ -21,7 +21,8 @@ from pyinotify import WatchManager, Notifier, ProcessEvent, IN_DELETE, IN_CREATE
# from gevent import monkey # from gevent import monkey
# monkey.patch_all() # monkey.patch_all()
# import gevent # 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 import paramiko
...@@ -200,8 +201,10 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler): ...@@ -200,8 +201,10 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
try: try:
data = '' data = ''
while True: while True:
wait_read(self.chan.fileno()) r, w, e = select.select([self.chan, sys.stdin], [], [])
if self.chan in r:
recv = self.chan.recv(1024) recv = self.chan.recv(1024)
print recv
if not len(recv): if not len(recv):
return return
data += recv data += recv
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment