bugfix
This commit is contained in:
parent
4f97384455
commit
e9f33f6a45
@ -216,18 +216,23 @@ class WebsocketProcessor(PythonScriptProcessor):
|
|||||||
lenv.update(params)
|
lenv.update(params)
|
||||||
params_kw = lenv.params_kw
|
params_kw = lenv.params_kw
|
||||||
userid = lenv.params_kw.userid or await lenv.get_user()
|
userid = lenv.params_kw.userid or await lenv.get_user()
|
||||||
|
debug(f'========== debug ===========')
|
||||||
del lenv['request']
|
del lenv['request']
|
||||||
txt = await self.loadScript(self.real_path)
|
txt = await self.loadScript(self.real_path)
|
||||||
ws = web.WebSocketResponse()
|
ws = web.WebSocketResponse()
|
||||||
|
debug(f'========== debug ===========')
|
||||||
try:
|
try:
|
||||||
await ws.prepare(request)
|
await ws.prepare(request)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('--------except:', e, type(e))
|
exception(f'--------except: {e}'))
|
||||||
print_exc()
|
print_exc()
|
||||||
raise e
|
raise e
|
||||||
|
debug(f'========== debug ===========')
|
||||||
ws_pool = WsPool(ws, request['client_ip'], request.path, request.app)
|
ws_pool = WsPool(ws, request['client_ip'], request.path, request.app)
|
||||||
|
debug(f'========== debug ===========')
|
||||||
async for msg in ws:
|
async for msg in ws:
|
||||||
if msg.type == aiohttp.WSMsgType.TEXT:
|
if msg.type == aiohttp.WSMsgType.TEXT:
|
||||||
|
debug(f'========== {msg=} ===========')
|
||||||
if msg.data == 'exit':
|
if msg.data == 'exit':
|
||||||
break
|
break
|
||||||
debug(f'WS:msg from client={msg}')
|
debug(f'WS:msg from client={msg}')
|
||||||
@ -237,11 +242,11 @@ class WebsocketProcessor(PythonScriptProcessor):
|
|||||||
func = lenv['myfunc']
|
func = lenv['myfunc']
|
||||||
resp = await func(request,**lenv)
|
resp = await func(request,**lenv)
|
||||||
elif msg.type == aiohttp.WSMsgType.ERROR:
|
elif msg.type == aiohttp.WSMsgType.ERROR:
|
||||||
info('ws connection closed with exception %s' % ws.exception())
|
error('ws connection closed with exception %s' % ws.exception())
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
info('datatype error', msg.type)
|
info('datatype error', msg.type)
|
||||||
info(f'========== ws connection end ===========')
|
debug(f'========== ws connection end ===========')
|
||||||
ws_pool.delete_me()
|
ws_pool.delete_me()
|
||||||
self.retResponse = ws
|
self.retResponse = ws
|
||||||
await ws.close()
|
await ws.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user