Skip to content
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

Nested event loop error is raised in SuiAsynchClient #41

Closed
CaffeineDuck opened this issue Dec 12, 2022 · 1 comment
Closed

Nested event loop error is raised in SuiAsynchClient #41

CaffeineDuck opened this issue Dec 12, 2022 · 1 comment

Comments

@CaffeineDuck
Copy link
Contributor

If we initiate SuiAsynchClient before running the main event loop or in different task, it raised the nested event loop error due to asyncio.get_event_loop() and loop.run_until_complete() method being used from asyncio. The code I've mentioned is used in

class SuiAsynchClient(_ClientMixin):
    """Sui Asyncrhonous Client."""

    def __init__(self, config: SuiConfig) -> None:
        """Client initializer."""
        super().__init__(config)
        self._client = httpx.AsyncClient(http2=True)
        self._rpc_api = {}
        self._schema_dict = {}
        loop = asyncio.get_event_loop()
        loop.run_until_complete(self._build_api_descriptors())

Using the synchronous version of self_build_api_descriptors() rather than loop.run_until_complete() will fix this issue as the risk of creation of multiple loops will be gone. Also the get_event_loop() method is deprecated too.

CaffeineDuck added a commit to CaffeineDuck/pysui that referenced this issue Dec 12, 2022
Uses sync `httpx` client for `_build_api_descriptors()` method in `SuiAsynchClient`.
Fixes the issue FrankC01#41
@FrankC01
Copy link
Owner

Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants