🏗️ make event handling in background

This commit is contained in:
yanyongyu 2020-09-08 15:55:53 +08:00
parent b3a796e726
commit 6d37417d21

View File

@ -3,6 +3,7 @@
import hmac import hmac
import json import json
import asyncio
import logging import logging
import uvicorn import uvicorn
@ -151,7 +152,7 @@ class Driver(BaseDriver):
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
detail="adapter not found") detail="adapter not found")
await bot.handle_message(data) asyncio.create_task(bot.handle_message(data))
return Response("", 204) return Response("", 204)
@overrides(BaseDriver) @overrides(BaseDriver)
@ -203,7 +204,7 @@ class Driver(BaseDriver):
if not data: if not data:
continue continue
await bot.handle_message(data) asyncio.create_task(bot.handle_message(data))
finally: finally:
del self._clients[x_self_id] del self._clients[x_self_id]