refactor: remove unreachable internal code paths
Co-authored-by: chengyongru <61816729+chengyongru@users.noreply.github.com>
This commit is contained in:
1 parent
4212ad726d
commit
9257383bec
21 files changed
+86
-285
No files matched your search
@@ -497,12 +497,12 @@ class DiscordChannel(BaseChannel):
|
||||
self.logger.exception("client startup failed")
|
||||
finally:
|
||||
self._running = False
|
||||
await self._reset_runtime_state(close_client=True)
|
||||
await self._reset_runtime_state()
|
||||
|
||||
async def stop(self) -> None:
|
||||
"""Stop the Discord channel."""
|
||||
self._running = False
|
||||
await self._reset_runtime_state(close_client=True)
|
||||
await self._reset_runtime_state()
|
||||
|
||||
def _remember_compaction_notice(
|
||||
self,
|
||||
@@ -907,7 +907,7 @@ class DiscordChannel(BaseChannel):
|
||||
await asyncio.gather(*tasks, return_exceptions=True)
|
||||
self._working_emoji_tasks.clear()
|
||||
|
||||
async def _reset_runtime_state(self, close_client: bool) -> None:
|
||||
async def _reset_runtime_state(self) -> None:
|
||||
self._running = False
|
||||
# Drain callbacks before clearing the state they can still create after an await.
|
||||
current = asyncio.current_task()
|
||||
@@ -921,7 +921,7 @@ class DiscordChannel(BaseChannel):
|
||||
self._compaction_notices.clear()
|
||||
self._stream_bufs.clear()
|
||||
self._known_channels.clear()
|
||||
if close_client and self._client is not None and not self._client.is_closed():
|
||||
if self._client is not None and not self._client.is_closed():
|
||||
try:
|
||||
await self._client.close()
|
||||
except Exception as e:
|
||||
|
||||
@@ -1850,6 +1850,6 @@ async def test_reset_discards_in_flight_compaction_notices() -> None:
|
||||
owner, client = _client_with_channel(target)
|
||||
await client.send_outbound(_compaction_message("Compressing context…", "started"))
|
||||
|
||||
await owner._reset_runtime_state(close_client=False)
|
||||
await owner._reset_runtime_state()
|
||||
|
||||
assert owner._compaction_notices == {}
|
||||
Reference in new issue
Block a user