Skip to content

Commit

Permalink
Use options.delay instead of DELAY
Browse files Browse the repository at this point in the history
  • Loading branch information
huashengdun committed Oct 7, 2020
1 parent 063b0ee commit d54f5b5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from urllib import urlencode


handler.DELAY = 0.1
swallow_http_errors = handler.swallow_http_errors
server_encodings = {e.strip() for e in Server.encodings}

Expand Down Expand Up @@ -99,6 +98,7 @@ def get_app(self):
options.hostfile = ''
options.syshostfile = ''
options.tdstream = ''
options.delay = 0.1
app = make_app(make_handlers(loop, options), get_app_settings(options))
return app

Expand Down Expand Up @@ -204,7 +204,7 @@ def test_app_with_correct_credentials_timeout(self):

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)
Expand Down
4 changes: 1 addition & 3 deletions webssh/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from urlparse import urlparse


DELAY = 3
DEFAULT_PORT = 22

swallow_http_errors = True
Expand Down Expand Up @@ -515,8 +514,7 @@ def post(self):
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)
Expand Down
2 changes: 1 addition & 1 deletion webssh/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def print_version(flag):
'*': 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')
Expand Down

0 comments on commit d54f5b5

Please sign in to comment.