mirror of
https://github.com/xcat2/confluent.git
synced 2026-09-29 00:31:09 +00:00
Prevent async protocol violation
The callback registration can result in a callback before we send ASYNCID. Guard by waiting for readiness to be signaled by loop.
This commit is contained in:
@@ -509,9 +509,12 @@ async def wsock_handler(req):
|
||||
return
|
||||
cfgmgr = httpsessions[sessid]['cfgmgr']
|
||||
username = httpsessions[sessid]['name']
|
||||
asyncready = False
|
||||
if req.rel_url.path == '/sessions/current/async':
|
||||
myconsoles = {}
|
||||
async def asyncwscallback(rspm):
|
||||
while not asyncready:
|
||||
await asyncio.sleep(0.1)
|
||||
rspm = json.dumps(rspm.raw())
|
||||
await rsp.send_str(u'!' + rspm)
|
||||
currsess['inflight'].add(rsp)
|
||||
@@ -520,6 +523,7 @@ async def wsock_handler(req):
|
||||
for asess in confluent.asynchttp.handle_async(
|
||||
{}, asyncwscallback):
|
||||
await rsp.send_str(u' ASYNCID: {0}'.format(asess.asyncid))
|
||||
asyncready = True
|
||||
clientmsg = True
|
||||
while clientmsg:
|
||||
clientmsg = await rsp.receive()
|
||||
|
||||
Reference in New Issue
Block a user