mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-01-31 23:51:28 +08:00
🏗️ make event handling in background
This commit is contained in:
parent
b3a796e726
commit
6d37417d21
@ -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]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user