release 0.1

This commit is contained in:
Cam 2022-11-26 12:40:15 +08:00
parent bc6b01b22d
commit 758108b346
4 changed files with 14 additions and 9 deletions

View File

@ -178,8 +178,6 @@ async def show():
- example/with_fastapi.py
与fastapi 配合使用的例子
- example/error_handler.py
错误处理的例子
## TODO

View File

@ -87,7 +87,7 @@ class BLiver(AsyncIOEventEmitter):
self.scheduler.start()
# 开始监听
while True:
while self.running:
try:
msg = await self.ws.receive(timeout=60)
if msg.type in (
@ -95,8 +95,9 @@ class BLiver(AsyncIOEventEmitter):
aiohttp.WSMsgType.CLOSED,
aiohttp.WSMsgType.ERROR,
):
await self.connect() # reconnect
continue
if self.running:
await self.connect() # reconnect
continue
if msg.type != aiohttp.WSMsgType.BINARY:
continue
mq = self.packman.unpack(msg.data)
@ -112,10 +113,11 @@ class BLiver(AsyncIOEventEmitter):
await self.connect()
async def graceful_close(self):
self.scheduler.shutdown()
await self._ws.close()
await self.aio_session.close()
self.running = False
self.scheduler.shutdown()
await self.aio_session.close()
await self.ws.close()
def run(self):
loop = asyncio.get_event_loop()

View File

@ -1,3 +1,4 @@
import uvicorn
from fastapi import FastAPI
from blive import BLiver, Events
from blive.msg import DanMuMsg
@ -41,3 +42,7 @@ async def rm_bliver(roomid: int):
@app.get("/show")
async def show():
return list(BLIVER_POOL.keys())
if __name__ == "__main__":
uvicorn.run(app)

View File

@ -5,7 +5,7 @@ with open("./README.md", "r") as f:
setuptools.setup(
name="blive",
version="0.0.9",
version="0.1.0",
author="cam",
author_email="yulinfeng000@gmail.com",
long_description=description,