Has anyone else ever had any trouble with AppleScript just stopping without any reason?
I’m experiencing problems with a big script that processes multiple files using multiple app’s.
Sometimes (usually when he’s doing multiple documents), the script just dies. It doens’t throw an error and I’m pretty sure a real error doesn’t happen, because it happens at different parts of the script. Sometimes Safari won’t close, sometimes Excel just doens’t continue doing what it’s supposed to.
Is this because AppleScript has some kind of TimeOut time if something takes to long without getting a response from the program it’s scripting?
Or something like that?
Hi,
you’ve to post your code first- i mean littel snippets of your code -i think that reflects a nice sense of affiliation with the comunity too.
I can suggest you to:
debug with dialogs,
insert error dialogs
call apps shortely, perhaps via shell script,
rewrite your code in a smarter way,
insert timeout clauses (from folder “action clause”, to find in the contextual menu of script editor)
… there are numerous possibilities. Minor number of apps are involved, and better results you get (in relationship to dependencies in general, perhaps you can do the same task with minor resources and via shell, and so forth…)
The reason I didn’t post the code is because it has over 600 lines and shortening it doesn’t make much sense either.
Here’s a part, I handle all the requests in a loop, and only carry on if the processing is finished:
on adding folder items to thisFolder after receiving addedItems
-- config and vars
try
repeat with theItem in addedItems
tell application "Finder" to set outputNameXml to the name of the file theItem
tell application "Finder" to set fileType to the name extension of theItem
if fileType is "xml" then
set ready to false
startHandler((theItem as text), errorCode, errorMessage, theList)
repeat while not ready
-- delay 1
end repeat
tell application "Finder" to delete (theItem as alias)
delay 1
end if
end repeat
end try
end adding folder items to
…and below follows a bunch of functions.
I debugged with dialogs, the script stops at different parts. Without throwing an error.
I have a pretty detailed errorhandling at every part of the script. No error occurs though. It just stops.
I need to call the app’s via AppleScript because I use their scripting lib. I could replace most of the Finder-calls with shell scripts though I guess
I rewrote my code quite a few times, I wouldn’t know how to make it any smarter.
I’ll look into to timeout-clauses.
Thanks for your tips. If anyone else has any ideas what could cause this, just assume it’s not a scripting-error, I’d be glad to hear it.
Thanks.
For anyone interested, I solved this issue by seperating the “loop requests” part of the script and the actual processing of the request.
I now loop the requests, then call the processer via osascript. It’s also faster this way.
Thanks for this posting! - I’m experiencing the exact same problem. My script triggers a batch sequence in Acrobat and waits (using a loop that calls delay 6 - changing that to do shell script “sleep 6” fails too) until the output file appears. Looking in the console log shows “com.apple.launchd[751] (com.apple.FolderActions.folders) Throttling respawn: Will start in 9 seconds” whenever my script runs. If I debug in Script Debugger or insert display alert messages, the script works, but when run normally it just quits. Can you please post a snippet showing what you mean by seperating the “loop requests” part of the script and the actual processing of the request?