Create a delay?

Posted on
Sat Nov 17, 2018 10:54 pm
mattyf offline
Posts: 58
Joined: Apr 15, 2013

Create a delay?

Hi. I'm starting to try and convert Applescripts, but honestly, I could barely understand Applescript when I set these up, so the thought of having to do that all over again is overwhelming. But here we go.

The first thing I tried was that I was using an Applescript to create a delay in a set of actions. So in python I tried:

import time
time.sleep(4)

That works fine, but time.sleep(60) results in a spinning beach ball after 4 or 5 seconds, then a pop-up message from indigo that says "stopping 'embedded script executor host.' This may take a few seconds." And the script stops.

Because I don't know Python AT ALL, I'm sure I'm doing something stupid, but... help?

Or is there some flow control function already built in to Indigo that I am missing?

Posted on
Sun Nov 18, 2018 2:40 am
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Re: Create a delay?

Have you tried the Scripting Tutorials? I've found them very useful when starting out - try this link - https://wiki.indigodomo.com/doku.php?id=indigo_7_documentation:plugin_scripting_tutorial
Also try this post of mine where I got plenty of help from others.
https://forums.indigodomo.com/viewtopic.php?f=107&t=18113

Posted on
Sun Nov 18, 2018 5:11 am
CliveS offline
Posts: 771
Joined: Jan 10, 2016
Location: Medomsley, County Durham, UK

Re: Create a delay?

Hi mattyf, welcome to the black art of coding Indigo with Python!

You are not alone believe me, just more brave to ask the "silly" question that loads of people on here want to ask but feel they can't.

I was in the same situation a year ago, no idea about Python but slowly am getting there.

As for your "beachball", any sleep command (or in fact ANY script) that is saved internally (embedded) and takes more than 10 seconds to run will be forced to stop as the whole of Indigo has stopped (so I believe!) so save it as a file with a .py extension (nameofscript.py) in the indigo7.2>scripts directory, mine are in a sub directory of python scripts so when Indigo goes to 7.3 it should move with it.

Upload your AppleScript to the "Converting to AppleScript" forum and you should get help in the conversion to python.

CliveS

Indigo 2023.2.0 : macOS Ventura 13.6.3 : Mac Mini M2 : 8‑core CPU and 10‑core GPU : 8 GB : 256GB SSD
----------------------------------------------------------------------------------
The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer

Posted on
Sun Nov 18, 2018 6:15 am
DaveL17 offline
User avatar
Posts: 6756
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Create a delay?

This is a feature of Indigo. Linked Python scripts (loaded from a file as noted above) can take as long as you like to complete because they're run in their own process.

From the docs:
The Execute Script action allows you to execute either a Python or AppleScript as an embedded script or stored in a script file. In general, you should use embedded scripts for scripts that are short and very quick to execute.

Embedded Python scripts will be limited to 10 seconds of execution time - if they run longer than that they will be killed. If you have a Python script that is a long running script you should save it in a separate file and execute it from the file by selecting the File radio button then selecting the file. Python scripts executed from files are executed in their own process and are therefore much less likely to adversely effect the server process if they don't work as expected.

Embedded AppleScripts must run on the server's main execution thread so if it delays, can hang on external events like network access, or otherwise does a lot of processing, then everything else in the server will be put on hold until the script is finished. Therefore, you definitely should keep embedded AppleScripts very simple. As with Python scripts, long running AppleScripts should be stored in a separate AppleScript file (created with Script Editor) and executed that way - external AppleScript files execute in their own process and are therefore much less likely to adversely effect the server process if they don't work as expected.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Nov 18, 2018 10:39 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Create a delay?

Post your AppleScripts (one per topic) in the Help Converting from AppleScript forum.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 7 guests