Timeout when calling a library
Timeout when calling a library
- Subject: Timeout when calling a library
- From: Stan Cleveland <email@hidden>
- Date: Thu, 10 Nov 2011 18:18:27 -0800
Hi all,
I have a question about an obscure AS detail. I've checked several of the AS books in my library and the ASLG at the developer site, but find nothing that directly answers it. First I'll give the situation, then the question, followed by what I've figured out so far.
The Situation:
I'm using a library with a handler that performs many operations that, taken together, may take several minutes to complete. However, no single operation would take more than a few seconds. Greatly simplified, the code that calls the library looks like this:
-- load the library
set _MyLib to load script alias "MacHD:Users:stanc:My Scripts:"
-- call the library
set remotePath to "123.45.67.89/ServerVol/Path/To/Some/Directory/"
set theResult to _MyLib's sftpDirectoryTraverse(remotePath)
return theResult
The Question:
Because the "sftpDirectoryTraverse" operation can take awhile, do I need to wrap the call to the library in a timeout block? Like this:
with timeout of 300 seconds
set theResult to _MyLib's sftpDirectoryTraverse(remotePath)
end timeout
return theResult
What I've Figured Out:
My research reveals that both the "with timeout" and "ignoring application responses" constructs only work when commands are targeted to an application. They are supposed to have no effect upon the current script or scripting additions. So I wonder, does a library act like an application WRT ignoring and timeouts? Or does it act is if it were a part of the calling script?
I wrapped the command with timeout limits of 5 seconds and then 1 second, neither of which caused a timeout. That might suggest the the library is NOT application-like and is just an extension of the main script.
But then I wrapped the command with an "ignoring application responses" block, which left the variable "theResult" undefined, indicating that the command WAS ignored. This suggests that the library DOES act like an application.
I'm confused. Based on the script's successful completion while under a 1-second timeout, I'm inclined to do nothing and go with AS's 120-second default timeout. But does anyone have any light to shed on this situation?
Thanks,
Stan C.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden