[Adium-devl] Blocking AppleScript Commands
Matt Handley
applmak at gmail.com
Tue Apr 22 02:02:53 UTC 2008
NSScriptCommand has a pair of methods suspendExecution/
resumeExecutionWithResult that allow other apple events to be
processed while the currentCommand is being worked on. Note that
because the script that called the first apple event is still waiting
for an answer it will not proceed until it gets a response. I think
that as long as these methods are used, we will be safe from the
errors you describe.
Matt
On Apr 21, 2008, at 5:48 PM, Evan Schoenberg wrote:
>
> On Apr 21, 2008, at 6:30 PM, Matt Handley wrote:
>
>> Would it be possible to try to wait (runMode:beforeDate:) until the
>> command timeout (which may be accessible from within Cocoa...)
>> elapses? Were that possible, then without a timeout specified, then
>> Adium would not block. Yet if the scripter wanted to be able to
>> specify the elapsed time, he would still have such a mechanism.
>>
>> The only things I see as preventing this from working is if: a) there
>> is no way to get the timeout field of the apple event (unlikely), b)
>> if the right NSRunLoop is hard to get to (we're multi-threaded,
>> right?), or c) if the NSRunLoop does tricky things that we don't
>> necessarily want to run over and over again while we're waiting for a
>> response from a server.
>
> One could certainly iterate on the run loop until a response is
> received, checking for the desired result after each iteration.
> Applescript can only run on the main thread; that run loop is easy to
> get.
>
> However, this opens a can of worms. What happens when iterating on the
> run loop triggers another Applescript to run, or the same Applescript
> to run? Hint: Applescript is not threadsafe and not re-entry safe.
> *boom*. Yes, it'll work sometimes... and crash one time in several
> hundred cases of re-entry.
>
> -Evan
>
> _______________________________________________
> Adium-devl mailing list
> Adium-devl at adiumx.com
> http://adiumx.com/mailman/listinfo/adium-devl_adiumx.com
More information about the devel
mailing list