Giter Club home page Giter Club logo

Comments (5)

oroulet avatar oroulet commented on August 23, 2024

you need to do a bit more asyncio training. you cannot use asyncio.run that way

from opcua-asyncio.

DinoFra avatar DinoFra commented on August 23, 2024

Hello, could you give me some tip?
Thank you

from opcua-asyncio.

schroeder- avatar schroeder- commented on August 23, 2024
  1. First dont post screenshoots, always add code as text. Also log outputs. It's hard to read and understand screenshoots.
  2. read about asyncio
  3. Here a incomplete example to use asyncio for your code:
    Remove asyncio.run(create_client()) from My_OPC_UA_Client init
async def run_client():
    client = My_OPC_UA_Client():
    await client.create_client()
    await client.get_node_ide("id")

if __name__ == "__main__":
    asyncio.run(run_client())
   

from opcua-asyncio.

DinoFra avatar DinoFra commented on August 23, 2024

Sorry for the screenshots.
I have read about that, the option mentioned only works if i want to run the script as the initial program entry point which doesn't happen.
I think the flow of my code, finishes the first asyncio.run() (when the object is created), i.e. the first event loop is closed, and after goes to the second asyncio.run() to execute the async function "getNodeId". I am not understanding the error.

from opcua-asyncio.

oroulet avatar oroulet commented on August 23, 2024

you need to have only one asyncio loop for the entire session (roughly). in a big application the the loop should be running already. Sounds like you in reality want to write sync code. Use the sync wrapper then

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.