Sleep() in script action

Posted on
Sat Nov 08, 2014 5:54 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Sleep() in script action

Is there anyway to sleep/pause/wait in an embedded script action?

I'm scripting AirFoil as per this thread but some actions are still overrunning each other.

My current task is to setup Airfoil for playing music (versus whatever I last used it for) - I am therefore disconnecting from all speakers (because I don't know which might be currently active or not), setting their desired volumes, then connecting to those where I want music playing. This works for the local speaker, but my Airport Express speakers are not reconnecting after I've set the volume, which matches the problem I had when doing this through regular Airfoil actions.

Each individual action works if I comment out the rest, so it's definitely an issue with timing.

Any ideas?

Peter

Posted on
Sat Nov 08, 2014 6:44 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Sleep() in script action

I've just added a loop (while x < 1000, log x, x + 1) before the re-connect, and it is now reconnecting 100% - which proves it is definitely timing.

Peter

Posted on
Sat Nov 08, 2014 9:33 am
autolog offline
Posts: 3988
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Sleep() in script action

Hi Peter,
Could you split the script in two and run them as two separate actions in an Action Group and delay the second action?

Posted on
Sat Nov 08, 2014 9:35 am
howartp offline
Posts: 4559
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Sleep() in script action

I could, which is kinda what I had initially (except using actions, not script) - but Jay suggested I script it which would theoretically solve all my problems.

I still don't understand if/why there isn't a sleep() command in Indigo?

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

Re: Sleep() in script action

http://www.tutorialspoint.com/python/time_sleep.htm

Though you'll have to be careful with embedded scripts - they're killed if they run longer than 10 seconds. You can just make it an external script to avoid that.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 9 guests