Move all async object creation to a proper initialisation point

This should make it so no object is created with another loop
This commit is contained in:
Rapptz
2022-03-13 08:26:39 -04:00
parent 8d4f08a5e7
commit 9c61e10a55
4 changed files with 45 additions and 27 deletions

View File

@@ -300,6 +300,9 @@ class ConnectionState:
else:
await coro(*args, **kwargs)
async def async_setup(self) -> None:
pass
@property
def self_id(self) -> Optional[int]:
u = self.user
@@ -1485,7 +1488,6 @@ class AutoShardedConnectionState(ConnectionState):
def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
self.shard_ids: Union[List[int], range] = []
self.shards_launched: asyncio.Event = asyncio.Event()
def _update_message_references(self) -> None:
# self._messages won't be None when this is called
@@ -1500,6 +1502,9 @@ class AutoShardedConnectionState(ConnectionState):
# channel will either be a TextChannel, Thread or Object
msg._rebind_cached_references(new_guild, channel) # type: ignore
async def async_setup(self) -> None:
self.shards_launched: asyncio.Event = asyncio.Event()
async def chunker(
self,
guild_id: int,