Git Product home page Git Product logo

Comments (2)

pavel-kirienko avatar pavel-kirienko commented on August 22, 2024

I hate to say this, but this is the expected behavior. The IPython kernel is executed in the main thread, so if your script blocks it for a significant amount of time, you will get all kinds of weird and wonderful glitches.

There are two solutions:

  • Move the IPython kernel into a separate process or thread. This involves much refactoring and hair pulling, so I'm not planning to do that anytime soon (however, a pull request is always welcome).
  • Use only asynchronous code. Seeing as you come from procedural background, it may require some getting used to. Your code can be refactored into async alternative roughly as follows (I didn't have a chance to test it) (there is also about one million other ways to do this):
i = 470
t = -1

def run_once():
    global i, t
    i *= 0.99
    c = int(i) + (1000 if t < 0 else 0)
    t = -t
    print('command', c)
    broadcast(uavcan.equipment.hardpoint.Command(hardpoint_id=1, command=c))
    if i > 20:
        node.defer(0.3, run_once)

node.defer(0, run_once)

from gui_tool.

pavel-kirienko avatar pavel-kirienko commented on August 22, 2024

http://uavcan.org/GUI_Tool/User_guide/#programming-tips

from gui_tool.

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.