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.


    Automatically run workflow/pythonscript every X seconds

    Editorial
    2
    3
    2219
    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.
    • jastor
      jastor last edited by

      Hi.

      The closest answer to this Ive found is notification.schedule('message',seconds_delay,'action_url')

      "Scheduled notifications are delivered even when your script (or even the entire app) is no longer running." Sounds great! If it was available for other stuff too that is (and if it already is, please tell me what Im supposed to look for, so far I haven't found it).

      I could add an action_url, but requiring interaction is something I don't want (to quote the docs: "It is also possible to attach a URL to a notification that is launched when the notification is activated (e.g. selected in Notification Center).").

      I was thinking of using a loop, but I haven't found out how to put an execution delay in python ;).

      Battery consumption is not an issue.

      Edit:
      Ok Ive found this http://omz-software.com/editorial/docs/library/threading.html#timer-objects lets just hope that your python supports it.

      Edit:
      Other than it was "threading" and not "thread" I got it working . .. Gonna try and see if I can get it running in the background.

      Edit:
      Doesn't run when another app got focus, much less when ipad is closed. Gonna experiment with forks and stuff and see if it works then.

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        You can't run code in the background (or when the screen is locked) for more than 10 minutes (approximately), it's an iOS limitation that you just can't get around.

        In general, I wouldn't really recommend using threads in Pythonista/Editorial. For one thing, the apps won't continue to run your code in the background if the main interpreter thread isn't active, and it can get somewhat problematic when your threads run amok (i.e. it's not really possible in Python to stop a thread). To do something every few seconds, you don't need threads anyway, just put something like time.sleep(1) in a loop...

        1 Reply Last reply Reply Quote 0
        • jastor
          jastor last edited by

          Yes, the threads was just to see if I could get it to run in the background when editorial wasnt running. It didnt work. Ohwell, Ill have to see if I can do a workaround to what I want. Thanks anyway :)

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