0

I am using this library https://github.com/liamw9534/pyconnman to control connman via python/dbus. The problem is that all the other modules that I'm using are usign async api.

How to convert this module to use async function calls?

In general, if I want a library to be available both in sync and async "way", what is the recommended pattern to use?

like

class myExampleConnectorClass:
    def

class myExampleAsyncConnectorClass:
    async def my_method(self):
        pass

class myCustomObj(myExampleConnectorClass):
    def my_method(self):
        return super().my_method()

How I can define the same derived class and decide when I instantiate it if I want the async or sync version?

Thanks Nick

4
  • How to write your own async coroutine function Commented Dec 11, 2019 at 10:20
  • If the mentioned library is not async/awaitable you cannot run it as asynchronous, you should run it sequentially. Commented Dec 11, 2019 at 10:25
  • Maybe I didn't explain myself. i have a libray not designed to be used with asyncio (is using glib eventloop I think) and I want to encapsulate it and use it with a library that is using async call. Can I encapsulate the main gio loop inside an asyncio coroutine and encapsulate the function call in some way? Commented Jan 28, 2020 at 11:53
  • I don't know correctly. However, there is a library which is called ray, it could convert an unawaitable method to add an asyncio loop. Here is an example Commented Jan 28, 2020 at 12:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.