Skip to content

Commit 03e3305

Browse files
committed
Delay subscription ticking when websocket is closed
1 parent c2583a7 commit 03e3305

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

discord/state.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

5656
from discord_protos import UserSettingsType
5757

58-
from .errors import ClientException, DiscordException, InvalidData, NotFound
58+
from .errors import ClientException, InvalidData, NotFound
5959
from .guild import Guild
6060
from .activity import BaseActivity, create_activity, Session
6161
from .user import User, ClientUser
@@ -105,7 +105,6 @@
105105
from .experiment import UserExperiment, GuildExperiment
106106
from .metadata import Metadata
107107
from .directory import DirectoryEntry
108-
from .backoff import ExponentialBackoff
109108

110109
if TYPE_CHECKING:
111110
from typing_extensions import Self
@@ -606,8 +605,12 @@ def _cancel(self) -> None:
606605
async def _tick_task(self) -> None:
607606
try:
608607
await asyncio.sleep(self.TICK_TIMEOUT)
609-
await self._flush()
610-
self._task = None
608+
if self._state.ws.open:
609+
await self._flush()
610+
self._task = None
611+
else:
612+
self._task = None
613+
self._tick()
611614
except asyncio.CancelledError:
612615
pass
613616

0 commit comments

Comments
 (0)