Fix memory leak in webhooks not deallocating locks

This commit is contained in:
Rapptz
2022-02-17 07:29:06 -05:00
parent 940bdb988a
commit 4fa2a6e63e
2 changed files with 4 additions and 2 deletions

View File

@ -38,6 +38,7 @@ import re
from urllib.parse import quote as urlquote
from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Tuple, Type, TypeVar, Union, overload
import weakref
from .. import utils
from ..errors import InvalidArgument, HTTPException, Forbidden, NotFound, DiscordServerError
@ -91,7 +92,7 @@ class DeferredLock:
class WebhookAdapter:
def __init__(self):
self._locks: Dict[Any, threading.Lock] = {}
self._locks: weakref.WeakValueDictionary[Any, threading.Lock] = weakref.WeakValueDictionary()
def request(
self,