1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

エラー対処記録: Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x000001FBD4006510>

Posted at

背景

Azure Service を使う script をつくろうとした際に起きたエラー。

エラーだけ見て、aiohttp だろうと思って失敗した記録

error
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001FBD4006510>
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001FBD3FCC2C0>

結論

非同期k Clients は終了させる必要があったという話。

clients.close
async def close(self):
    await self.cosmos_client.close()
    await self.search_client.close()

詳細

同期 clients なら、close() は不要だが、
非同期 clients は、close() が必要って話

同期⇒非同期へと切り替えると色々違ってて失敗しますね。

async CosmosClient.close()
async def close(self) -> None:
    """Close this instance of CosmosClient."""
    await self.__aexit__()

あとがき

エラーだけ見ると、aiohttp 使ってるところを探しちゃって少しはまりますね・・ :sweat:

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?