Skip to content

Commit a50aae7

Browse files
committed
增加超时配置
1 parent 5e23abf commit a50aae7

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/ansible_api/config.py

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Config(object):
2323
allow_ip = []
2424
ws_sub = []
2525
workers = 1 # default is one worker, multi-worker will case BUG of websocket broadcast
26+
timeout = 3600 # timeout for waiting response
2627

2728
dir_script = ''
2829
dir_playbook = ''
@@ -43,6 +44,7 @@ def __init__(self):
4344
'allow_ip') else Config.allow_ip
4445
self.workers = int(cf.get('default', 'workers')) if cf.has_option('default', 'workers') else Config.workers
4546
self.ws_sub = cf.get('default', 'ws_sub').split() if cf.has_option('default', 'ws_sub') else Config.ws_sub
47+
self.timeout = int(cf.get('default', 'timeout')) if cf.has_option('default', 'timeout') else Config.timeout
4648

4749
try:
4850
cf.options('directory')

src/ansible_api/server.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self, daemon):
3131
app.add_route(controller.ParseVarsFromFile.as_view(), '/parsevars')
3232
app.add_websocket_route(controller.Message.websocket, '/message', subprotocols=Config.get('ws_sub'))
3333

34-
app.config.update(dict(RESPONSE_TIMEOUT=1800)) # timeout for waiting response
34+
app.config.update(dict(RESPONSE_TIMEOUT=Config.get('timeout'))) # timeout for waiting response
3535

3636
@app.middleware('request')
3737
async def ip_ban(request):

0 commit comments

Comments
 (0)