2024-07-24 14:51:10.569 | ERROR | task_manager:109 | - Failed to add task 633276 due to: RuntimeError('Session is closed')
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/root/blrec/src/blrec/task/task_manager.py", line 105, in add_task
await task.enable_monitor()
File "/root/blrec/src/blrec/task/task.py", line 457, in enable_monitor
await self._danmaku_client.start()
File "/root/blrec/src/blrec/utils/mixins.py", line 98, in start
await self._do_start()
File "/root/blrec/src/blrec/bili/danmaku_client.py", line 104, in _do_start
await self._connect()
File "/root/blrec/.venv/lib/python3.11/site-packages/tenacity/asyncio/__init__.py", line 189, in async_wrapped
return await copy(fn, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/tenacity/asyncio/__init__.py", line 111, in __call__
do = await self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/tenacity/asyncio/__init__.py", line 153, in iter
result = await action(retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/tenacity/_utils.py", line 99, in inner
return call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/tenacity/__init__.py", line 398, in <lambda>
self._add_action_func(lambda rs: rs.outcome.result())
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/root/blrec/.venv/lib/python3.11/site-packages/tenacity/asyncio/__init__.py", line 114, in __call__
result = await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/src/blrec/bili/danmaku_client.py", line 138, in _connect
await self._connect_websocket()
File "/root/blrec/src/blrec/bili/danmaku_client.py", line 160, in _connect_websocket
self._ws = await self.session.ws_connect(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/aiohttp/client.py", line 835, in _ws_connect
resp = await self.request(
^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/aiohttp/client.py", line 428, in _request
raise RuntimeError("Session is closed")
RuntimeError: Session is closed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/blrec/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 419, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 270, in __call__
await super().__call__(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/applications.py", line 124, in __call__
await self.middleware_stack(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/root/blrec/src/blrec/web/middlewares/route_redirect.py", line 25, in __call__
await self._app(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 92, in __call__
await self.simple_response(scope, receive, send, request_headers=headers)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 147, in simple_response
await self.app(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/brotli_asgi/__init__.py", line 85, in __call__
await gzip_responder(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/gzip.py", line 44, in __call__
await self.app(scope, receive, self.send_with_gzip)
File "/root/blrec/src/blrec/web/middlewares/base_herf.py", line 16, in __call__
await self._app(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/root/blrec/.venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
raise e
File "/root/blrec/.venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/routing.py", line 706, in __call__
await route.handle(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 235, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 161, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/src/blrec/web/routers/tasks.py", line 249, in add_task
real_room_id = await app.add_task(room_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/src/blrec/application.py", line 152, in add_task
await self._task_manager.add_task(settings)
File "/root/blrec/.venv/lib/python3.11/site-packages/tenacity/asyncio/__init__.py", line 189, in async_wrapped
return await copy(fn, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/tenacity/asyncio/__init__.py", line 111, in __call__
do = await self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/tenacity/asyncio/__init__.py", line 153, in iter
result = await action(retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/tenacity/_utils.py", line 99, in inner
return call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/tenacity/__init__.py", line 398, in <lambda>
self._add_action_func(lambda rs: rs.outcome.result())
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/root/blrec/.venv/lib/python3.11/site-packages/tenacity/asyncio/__init__.py", line 114, in __call__
result = await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/src/blrec/task/task_manager.py", line 111, in add_task
del self._tasks[settings.room_id]
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 633276
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/root/blrec/.venv/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 419, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 270, in __call__
await super().__call__(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/applications.py", line 124, in __call__
await self.middleware_stack(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
raise exc
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
await self.app(scope, receive, _send)
File "/root/blrec/src/blrec/web/middlewares/route_redirect.py", line 25, in __call__
await self._app(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 92, in __call__
await self.simple_response(scope, receive, send, request_headers=headers)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 147, in simple_response
await self.app(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/brotli_asgi/__init__.py", line 85, in __call__
await gzip_responder(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/gzip.py", line 44, in __call__
await self.app(scope, receive, self.send_with_gzip)
File "/root/blrec/src/blrec/web/middlewares/base_herf.py", line 16, in __call__
await self._app(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
raise exc
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
await self.app(scope, receive, sender)
File "/root/blrec/.venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
raise e
File "/root/blrec/.venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
await self.app(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/routing.py", line 706, in __call__
await route.handle(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/root/blrec/.venv/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 235, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 161, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/blrec/src/blrec/web/routers/tasks.py", line 265, in remove_task
await app.remove_task(room_id)
File "/root/blrec/src/blrec/application.py", line 158, in remove_task
await self._task_manager.remove_task(room_id)
File "/root/blrec/src/blrec/task/task_manager.py", line 120, in remove_task
await task.disable_monitor()
File "/root/blrec/src/blrec/task/task.py", line 466, in disable_monitor
await self._danmaku_client.stop()
File "/root/blrec/src/blrec/utils/mixins.py", line 106, in stop
await self._do_stop()
File "/root/blrec/src/blrec/bili/danmaku_client.py", line 109, in _do_stop
await self._terminate_message_loop()
File "/root/blrec/src/blrec/bili/danmaku_client.py", line 280, in _terminate_message_loop
self._message_loop_task.cancel()
^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DanmakuClient' object has no attribute '_message_loop_task'