commit d54f5b547a55aa6722e8f951b3f551dca5fa2b27
parent 063b0ee5cf76fbbd3470111837104d9e233face8
Author: Sheng <webmaster0115@gmail.com>
Date: Wed, 7 Oct 2020 20:29:13 +0800
Use options.delay instead of DELAY
Diffstat:
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/tests/test_app.py b/tests/test_app.py
@@ -23,7 +23,6 @@ except ImportError:
from urllib import urlencode
-handler.DELAY = 0.1
swallow_http_errors = handler.swallow_http_errors
server_encodings = {e.strip() for e in Server.encodings}
@@ -99,6 +98,7 @@ class TestAppBasic(TestAppBase):
options.hostfile = ''
options.syshostfile = ''
options.tdstream = ''
+ options.delay = 0.1
app = make_app(make_handlers(loop, options), get_app_settings(options))
return app
@@ -204,7 +204,7 @@ class TestAppBasic(TestAppBase):
url = url.replace('http', 'ws')
ws_url = url + 'ws?id=' + data['id']
- yield tornado.gen.sleep(handler.DELAY + 0.1)
+ yield tornado.gen.sleep(options.delay + 0.1)
ws = yield tornado.websocket.websocket_connect(ws_url)
msg = yield ws.read_message()
self.assertIsNone(msg)
diff --git a/webssh/handler.py b/webssh/handler.py
@@ -30,7 +30,6 @@ except ImportError:
from urlparse import urlparse
-DELAY = 3
DEFAULT_PORT = 22
swallow_http_errors = True
@@ -515,8 +514,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
clients[ip] = workers
worker.src_addr = (ip, port)
workers[worker.id] = worker
- self.loop.call_later(options.delay or DELAY, recycle_worker,
- worker)
+ self.loop.call_later(options.delay, recycle_worker, worker)
self.result.update(id=worker.id, encoding=worker.encoding)
self.write(self.result)
diff --git a/webssh/settings.py b/webssh/settings.py
@@ -44,7 +44,7 @@ separated by comma;
'*': wildcard policy, matches any domain, allowed in debug mode only.''')
define('wpintvl', type=int, default=0, help='Websocket ping interval')
define('timeout', type=int, default=3, help='SSH connection timeout')
-define('delay', type=int, default=0, help='The delay to call recycle_worker')
+define('delay', type=float, default=3, help='The delay to call recycle_worker')
define('maxconn', type=int, default=20,
help='Maximum live connections (ssh sessions) per client')
define('font', default='', help='custom font filename')