• 카테고리

    질문 & 답변
  • 세부 분야

    웹 개발

  • 해결 여부

    미해결

채팅방 삭제 관련 오류가 뭐때문인지 모르겠습니다..

23.03.06 16:44 작성 조회수 452

0

안녕하세요

새 프로젝트를 만들어서 강사님 강의대로 구현했을 때에는 에러가 뜨지 않았는데요

제가 하던 간단한 프로젝트에서 채팅기능 추가하려고 하니까, 에러가 나네요..

강의 동영상 7분전까지는 오류없이 채팅방 삭제가 잘 되었는데요. 8분쯤 나오는 채팅방 삭제에 따른 웹소켓 연결 끊기 부분에서 잘못된것 같습니다.

채팅방을 만든 상태에서 채팅방을 삭제하면

WebSocket DISCONNECT /ws/chat/11/chat/ [127.0.0.1:54878]
Task exception was never retrieved
future: <Task finished name='Task-335' coro=<Connection.disconnect() done, defined at /Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py:723> exception=RuntimeError("Task <Task pending name='Task-335' coro=<Connection.disconnect() running at /Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py:736>> got Future <Future pending> attached to a different loop")>
Traceback (most recent call last):
  File "/Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py", line 736, in disconnect
    await self._writer.wait_closed()  # type: ignore[union-attr]
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/streams.py", line 344, in wait_closed
    await self._protocol._get_close_waiter(self)
RuntimeError: Task <Task pending name='Task-335' coro=<Connection.disconnect() running at /Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py:736>> got Future <Future pending> attached to a different loop
Task exception was never retrieved
future: <Task finished name='Task-336' coro=<Connection.disconnect() done, defined at /Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py:723> exception=RuntimeError("Task <Task pending name='Task-336' coro=<Connection.disconnect() running at /Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py:736>> got Future <Future pending> attached to a different loop")>
Traceback (most recent call last):
  File "/Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py", line 736, in disconnect
    await self._writer.wait_closed()  # type: ignore[union-attr]
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/streams.py", line 344, in wait_closed
    await self._protocol._get_close_waiter(self)
RuntimeError: Task <Task pending name='Task-336' coro=<Connection.disconnect() running at /Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py:736>> got Future <Future pending> attached to a different loop

이렇게 나옵니다. 검색해도 잘 모르겠습니다...

새로운 프로젝트만들어서 했을 때에는 이런 오류가 안떴는데 패키지 버전문제일까요??

답변 1

답변을 작성해보세요.

0

안녕하세요.

에러화면 만으로는 질문의 맥락을 모두 파악하기가 어렵네요.

위 오류의 재현과정을 순서대로 좀 더 상세히 설명해주시겠어요?

구현과정에 대한 맥락이 파악이 되어야, 제가 보다 좋은 답변을 드릴 수 있을 듯 합니다.

화이팅입니다. :-)

AeGin님의 프로필

AeGin

질문자

2023.03.06

위 강의내용대로

views.py 에서 room_delete를 구현했고

urls.py 에서 라우팅 지정하고,

여기까지 한 다음에 템플릿에서 채팅방 삭제 url 버튼을 등록해서 삭제하면 제대로 채팅방이 삭제가 됐었습니다.

 

그런데, 채팅방을 삭제할 때 웹소켓을 통해서 채팅방 유저에게 채팅방 삭제를 알리는 구현과정에서,

def room__on_post_delete 시그널을 등록하고, ChatConsumer 에서 커스텀 종료코드와 함께 웹소켓 연결을 끊는 과정에서 뭔가 처리가 잘 안되는 것 같습니다.

채팅방을 삭제하기를 눌렀을 때, 제가 처음에 올린 에러 코드가 뜨구요...

근데, admin에서 채팅방을 삭제를 했을 때에는 modal창이 뜨면서 제대로 동작하네요

admin을 통한 삭제에서는 의도하신 대로 동작을 한다면, model signal은 동작을 한다고 봐야겠구요. 직접 뷰를 통한 삭제에서 뭔가 맞지 않는 부분이 있는 듯 합니다.

가능하다면 전체 프로젝트 코드와 함께, 제가 해당 이슈를 재현해볼 수 있도록, 오류 재현과정도 설명해주시면, 제가 보다 좋은 답변을 드릴 수 있을 듯 합니다.