omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Asyncio does not work on the UI.

    Pythonista
    ui.button asyncio
    3
    3
    1021
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Lami
      Lami last edited by

      I want to run Asyncio from the UI button, but I get the error "there is no current event loop in thread 'dummy -1'" and cannot run it.
      Is there a way to define a loop?
      When I define a new loop using new and set, the UI freezes, so I predict that the UI also uses Asyncio and there is a conflict.
      Is there any way to avoid it?

      def button(sender):
               loop = asyncio.get_event_loop_policy().new_event_loop() #there is no current event loop in thread 'dummy -1
              gather = asyncio.gather(
                  get_pass(target),
                  get_pass(target),
                  get_pass(target)
              )
              loop.run_until_complete(gather)
      
      v=ui.load_view()
      v['imageview1'].image=ui.Image('img/image.png')
      v['imageview2'].image=ui.Image('img/image2.png')
      v.present('sheet', hide_title_bar = True)
      
      
      JonB 1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        https://omz-software.com/pythonista/docs/ios/ui.html#ui.in_background

        1 Reply Last reply Reply Quote 0
        • JonB
          JonB @Lami last edited by

          @Lami this is probably the definitive thread relating to threads and pythonista.

          https://forum.omz-software.com/topic/4528/help-me-understand-pythonista-s-threads

          You might consider setting up your thread pool executer outside of the button action.

          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          Powered by NodeBB Forums | Contributors