Skip to content

release: 0.2.0-alpha.46 #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Mar 17, 2025
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ec47eb9
chore(internal): codegen related update (#425)
stainless-app[bot] Mar 14, 2025
db32afe
test: add DEFER_PYDANTIC_BUILD=false flag to tests (#427)
stainless-app[bot] Mar 14, 2025
7111d6d
chore(internal): remove extra empty newlines (#428)
stainless-app[bot] Mar 14, 2025
10f1de0
feat(api): api update
stainless-app[bot] Jan 23, 2025
c87c92d
chore(internal): codegen related update
stainless-app[bot] Jan 24, 2025
dfd7861
chore(internal): codegen related update
stainless-app[bot] Jan 28, 2025
aefb7d9
fix(tests): correctly generate examples with writeOnly fields
stainless-app[bot] Jan 29, 2025
32452f0
chore(internal): change default timeout to an int
stainless-app[bot] Feb 4, 2025
a85525a
chore(internal): bummp ruff dependency
stainless-app[bot] Feb 4, 2025
919377e
feat(client): send `X-Stainless-Read-Timeout` header
stainless-app[bot] Feb 6, 2025
df06aaa
chore(internal): fix type traversing dictionary params
stainless-app[bot] Feb 7, 2025
a920965
chore(internal): minor type handling changes
stainless-app[bot] Feb 7, 2025
c7a8995
chore(internal): update client tests
stainless-app[bot] Feb 13, 2025
1aa358a
fix: asyncify on non-asyncio runtimes
stainless-app[bot] Feb 14, 2025
6a582f7
feat(client): allow passing `NotGiven` for body
stainless-app[bot] Feb 21, 2025
9bc507d
chore(internal): fix devcontainers setup
stainless-app[bot] Feb 22, 2025
0124a23
chore(internal): properly set __pydantic_private__
stainless-app[bot] Feb 26, 2025
1946b4f
chore(internal): fix workflows
Mar 14, 2025
395275b
chore(internal): codegen related update (#429)
stainless-app[bot] Mar 15, 2025
9fe86fe
chore(internal): bump rye to 0.44.0 (#430)
stainless-app[bot] Mar 15, 2025
3a8b9c1
fix(types): handle more discriminated union shapes (#431)
stainless-app[bot] Mar 15, 2025
5e2ab9d
release: 0.2.0-alpha.46
stainless-app[bot] Mar 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: asyncify on non-asyncio runtimes
  • Loading branch information
stainless-app[bot] authored and meorphis committed Mar 14, 2025
commit 1aa358aefbee3ddb9c401eb3e6838b063ba26f1e
19 changes: 17 additions & 2 deletions src/openlayer/_utils/_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@
from typing import Any, TypeVar, Callable, Awaitable
from typing_extensions import ParamSpec

import anyio
import sniffio
import anyio.to_thread

T_Retval = TypeVar("T_Retval")
T_ParamSpec = ParamSpec("T_ParamSpec")


if sys.version_info >= (3, 9):
to_thread = asyncio.to_thread
_asyncio_to_thread = asyncio.to_thread
else:
# backport of https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread
# for Python 3.8 support
async def to_thread(
async def _asyncio_to_thread(
func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
) -> Any:
"""Asynchronously run function *func* in a separate thread.
Expand All @@ -34,6 +38,17 @@ async def to_thread(
return await loop.run_in_executor(None, func_call)


async def to_thread(
func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
) -> T_Retval:
if sniffio.current_async_library() == "asyncio":
return await _asyncio_to_thread(func, *args, **kwargs)

return await anyio.to_thread.run_sync(
functools.partial(func, *args, **kwargs),
)


# inspired by `asyncer`, https://github.com/tiangolo/asyncer
def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
"""
Expand Down