Skip to content

Commit bb552bc

Browse files
committed
Remove anyio from runtime dependencies
1 parent 879cb27 commit bb552bc

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

elasticsearch/_async/helpers.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
import asyncio
1819
import logging
1920
from typing import (
2021
Any,
@@ -32,7 +33,7 @@
3233
Union,
3334
)
3435

35-
import anyio
36+
import sniffio
3637

3738
from ..exceptions import ApiError, NotFoundError, TransportError
3839
from ..helpers.actions import (
@@ -54,6 +55,15 @@
5455
T = TypeVar("T")
5556

5657

58+
async def _sleep(seconds: float) -> None:
59+
if sniffio.current_async_library() == "trio":
60+
import trio
61+
62+
await trio.sleep(seconds)
63+
else:
64+
await asyncio.sleep(seconds)
65+
66+
5767
async def _chunk_actions(
5868
actions: AsyncIterable[_TYPE_BULK_ACTION_HEADER_AND_BODY],
5969
chunk_size: int,

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dependencies = [
4545
"elastic-transport @ git+https://github.com/pquentin/elastic-transport-python.git@trio-support",
4646
"python-dateutil",
4747
"typing-extensions",
48-
"anyio",
48+
"sniffio",
4949
]
5050

5151
# TODO revert before merging/releasing
@@ -86,7 +86,7 @@ dev = [
8686
"jinja2",
8787
"tqdm",
8888
"trio",
89-
"sniffio",
89+
"anyio",
9090
"mypy",
9191
"pyright",
9292
"types-python-dateutil",

0 commit comments

Comments
 (0)