Re: Simultaneous Events (in AS CGI's)
Re: Simultaneous Events (in AS CGI's)
- Subject: Re: Simultaneous Events (in AS CGI's)
- From: cris <email@hidden>
- Date: Thu, 19 Apr 2001 23:22:21 +0200
on 19.04.2001 11:33 Uhr, Simon Forster at email@hidden wrote:
>
In the last couple of days there have been at least 2 posts asking how
>
AppleScript applications and/or AppleEvents handle simultaneous events. I'd
>
like to know this too.
>
>
For my part, I wrote an AppleScript CGI which would "email this web page to
>
a friend". It worked fine except, if the CGI was handling a request,
>
subsequent requests seemed to be ignored until the current task had been
>
completed. How to work around this?
>
>
I imagine that each event should instantiate a new AppleScript object -
>
although whether this is possible in AppleScript and how one does this is
>
unclear to me at this point in time.
>
>
Any pointers to understanding how AppleScript can handle simultaneous events
>
would be appreciated.
AppleScript CGI's are based on a LIFO (last in first out) concept. Your
observation is wrong, subsequent requests are executed immediately, which is
a real problem if the cgi get's more traffic than it can actual handle. In
such a situation nobody get's an answer from the script. A FIFO based cgi
would at least serve it's maximum it can handle.
Furthermore LIFO means you have to be very careful with variables declared
as globals. Use globals only for variables that never change their values
during the script is working.
The values of local variables are always held when a subsequent request
interrupts the current script run. A global variable will be overridden by
the subsequent request, meaning that the earlier request will continue it's
work with wrong variable values when the subsequent request has finished.
cris :-)
--
English is my second language.
www.cooc.de