mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
Fix memory leak in webhooks not deallocating locks
This commit is contained in:
parent
940bdb988a
commit
4fa2a6e63e
@ -32,6 +32,7 @@ import re
|
|||||||
from urllib.parse import quote as urlquote
|
from urllib.parse import quote as urlquote
|
||||||
from typing import Any, Dict, List, Literal, NamedTuple, Optional, TYPE_CHECKING, Tuple, Union, overload
|
from typing import Any, Dict, List, Literal, NamedTuple, Optional, TYPE_CHECKING, Tuple, Union, overload
|
||||||
from contextvars import ContextVar
|
from contextvars import ContextVar
|
||||||
|
import weakref
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
@ -95,7 +96,7 @@ class AsyncDeferredLock:
|
|||||||
|
|
||||||
class AsyncWebhookAdapter:
|
class AsyncWebhookAdapter:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._locks: Dict[Any, asyncio.Lock] = {}
|
self._locks: weakref.WeakValueDictionary[Any, asyncio.Lock] = weakref.WeakValueDictionary()
|
||||||
|
|
||||||
async def request(
|
async def request(
|
||||||
self,
|
self,
|
||||||
|
@ -38,6 +38,7 @@ import re
|
|||||||
|
|
||||||
from urllib.parse import quote as urlquote
|
from urllib.parse import quote as urlquote
|
||||||
from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Tuple, Type, TypeVar, Union, overload
|
from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Tuple, Type, TypeVar, Union, overload
|
||||||
|
import weakref
|
||||||
|
|
||||||
from .. import utils
|
from .. import utils
|
||||||
from ..errors import InvalidArgument, HTTPException, Forbidden, NotFound, DiscordServerError
|
from ..errors import InvalidArgument, HTTPException, Forbidden, NotFound, DiscordServerError
|
||||||
@ -91,7 +92,7 @@ class DeferredLock:
|
|||||||
|
|
||||||
class WebhookAdapter:
|
class WebhookAdapter:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._locks: Dict[Any, threading.Lock] = {}
|
self._locks: weakref.WeakValueDictionary[Any, threading.Lock] = weakref.WeakValueDictionary()
|
||||||
|
|
||||||
def request(
|
def request(
|
||||||
self,
|
self,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user