Skip to content

Use sync API in event loop #41

@jacobtomlinson

Description

@jacobtomlinson

Currently the sync API cannot be used in an asyncio event loop. We have an xfailing test which was added in #40 to demonstrate this.

@pytest.mark.xfail(reason="Cannot run nested event loops", raises=RuntimeError)
async def test_version_sync_in_async():
kubernetes = kr8s.api()
version = kubernetes.version()
assert "major" in version

This situation will come up a lot in Jupyter as there is always an event loop running but many users may expect to be able to use the sync API and will not consider asyncio at all.

We need to be able to support the sync API (which uses asyncio.run under the hood) in an event loop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingkr8s

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions