Giter Club home page Giter Club logo

Comments (6)

oroulet avatar oroulet commented on June 4, 2024

That is not how async programming works. Try a few python asyncio tutorial first

from opcua-asyncio.

Ajinkya-Suranis avatar Ajinkya-Suranis commented on June 4, 2024

That is not how async programming works. Try a few python asyncio tutorial first

I've already gone through basic tutorial. My main program is synchronous, and it needs to execute asynchronous coroutines (connect, browse nodes, read values etc) whenever necessary. That's why asyncio.run() is used for execution at those places. I've used similar approach at multiple places in my program (other than opcua) and it works perfectly.
My expectation is - Using asyncio.run() should always work in a synchronous program.

from opcua-asyncio.

AndreasHeine avatar AndreasHeine commented on June 4, 2024

use the sync wrapper if your code is sync

from opcua-asyncio.

Ajinkya-Suranis avatar Ajinkya-Suranis commented on June 4, 2024

use the sync wrapper if your code is sync

asyncio.run() would act like a sync wrapper, if I'm not wrong. Can you suggest an alternative?

from opcua-asyncio.

oroulet avatar oroulet commented on June 4, 2024

Calling async code from sync is not that easy. You need a loop running in a thread. But luckily for you I have done that work and you can use the sync wrappers. Look at the sync examples in repository

from opcua-asyncio.

Ajinkya-Suranis avatar Ajinkya-Suranis commented on June 4, 2024

Calling async code from sync is not that easy. You need a loop running in a thread. But luckily for you I have done that work and you can use the sync wrappers. Look at the sync examples in repository

Thanks a lot. Being a newbie in asyncio, I didn't quite give a lot of thought in sync->async handling before opening the issue. BTW, the run_until_complete() method of asyncio worked in this case, since it runs event loop till completion.

from opcua-asyncio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.