Support official contextlib.aclosing() when it's available.

This commit is contained in:
Jonathan Moody 2022-04-29 08:39:31 -04:00
parent fe07aac79c
commit fad84c771c

View file

@ -130,6 +130,10 @@ def get_sd_hash(stream_info):
def json_dumps_pretty(obj, **kwargs):
return json.dumps(obj, sort_keys=True, indent=2, separators=(',', ': '), **kwargs)
try:
# the standard contextlib.aclosing() is available in 3.10+
from contextlib import aclosing
except ImportError:
@contextlib.asynccontextmanager
async def aclosing(thing):
try: