mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-12-08 08:22:19 +00:00
Revert "Move global user storage from WeakValueDictionary to dict"
This reverts commit cb2363f0fd.
This lead to memory leaks due to insufficient tracking, assuming that
the members intent was enabled.
This commit is contained in:
@@ -429,29 +429,12 @@ class User(BaseUser, discord.abc.Messageable):
|
||||
Specifies if the user is a system user (i.e. represents Discord officially).
|
||||
"""
|
||||
|
||||
__slots__ = ('_stored',)
|
||||
|
||||
def __init__(self, *, state: ConnectionState, data: UserPayload) -> None:
|
||||
super().__init__(state=state, data=data)
|
||||
self._stored: bool = False
|
||||
__slots__ = ('__weakref__',)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f'<User id={self.id} name={self.name!r} discriminator={self.discriminator!r} bot={self.bot}>'
|
||||
|
||||
def __del__(self) -> None:
|
||||
try:
|
||||
if self._stored:
|
||||
self._state.deref_user(self.id)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def _copy(cls, user: User):
|
||||
self = super()._copy(user)
|
||||
self._stored = False
|
||||
return self
|
||||
|
||||
async def _get_channel(self) -> DMChannel:
|
||||
async def _get_channel(self):
|
||||
ch = await self.create_dm()
|
||||
return ch
|
||||
|
||||
|
||||
Reference in New Issue
Block a user