MAINT Use ordinary asyncio.gather in micropip tests (#2611)

This commit is contained in:
Hood Chatham 2022-05-24 20:29:04 -07:00 committed by GitHub
parent 693ee011c4
commit a525c54d66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 19 deletions

View File

@ -6,23 +6,20 @@ if IN_BROWSER:
WHEEL_BASE,
fetch_bytes,
fetch_string,
gather,
loadedPackages,
pyodide_js,
)
else:
from ._compat_not_in_pyodide import ( # type: ignore[no-redef]
from ._compat_not_in_pyodide import (
BUILTIN_PACKAGES,
WHEEL_BASE,
fetch_bytes,
fetch_string,
gather,
loadedPackages,
pyodide_js,
)
__all__ = [
"gather",
"fetch_bytes",
"fetch_string",
"WHEEL_BASE",

View File

@ -1,4 +1,3 @@
from asyncio import gather
from pathlib import Path
from pyodide._core import IN_BROWSER
@ -31,7 +30,6 @@ async def fetch_string(url: str, kwargs: dict[str, str]) -> str:
__all__ = [
"gather",
"fetch_bytes",
"fetch_string",
"WHEEL_BASE",

View File

@ -24,17 +24,6 @@ async def fetch_string(url: str, kwargs: dict[str, str]) -> str:
return (await fetch_bytes(url, kwargs)).decode()
# asyncio.gather will schedule any coroutines to run on the event loop but
# we want to avoid using the event loop at all. Instead just run the
# coroutines in sequence.
# TODO: Use an asyncio testing framework to avoid this
async def gather(*coroutines):
result = []
for coroutine in coroutines:
result.append(await coroutine)
return result
class pyodide_js_:
def __get__(self, attr):
raise RuntimeError(f"Attempted to access property '{attr}' on pyodide_js dummy")
@ -44,7 +33,6 @@ pyodide_js: Any = pyodide_js_()
__all__ = [
"gather",
"fetch_bytes",
"fetch_string",
"WHEEL_BASE",

View File

@ -2,6 +2,7 @@ import asyncio
import hashlib
import importlib
import json
from asyncio import gather
from dataclasses import dataclass, field
from importlib.metadata import PackageNotFoundError
from importlib.metadata import distributions as importlib_distributions
@ -24,7 +25,6 @@ from ._compat import (
WHEEL_BASE,
fetch_bytes,
fetch_string,
gather,
loadedPackages,
pyodide_js,
)