script failing at same line

script failing at same line

am 04.09.2009 22:31:21 von jim white

Hi,

I have a script that intermittently fails at the same line. I am trying
to write some code that will throw an exception after 5 seconds if the
command on that line fails and the script freezes.
Any ideas?

Jim White


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: script failing at same line

am 04.09.2009 23:01:31 von Jay Blanchard

[snip]
I have a script that intermittently fails at the same line. I am trying=20
to write some code that will throw an exception after 5 seconds if the=20
command on that line fails and the script freezes.
Any ideas?
[/snip]

I have lots of ideas! But those really won't help you :)

We need to see the code at that line and be told what is being done in
order to make a reasonable guess.

My bet is that the data being fed to the script has a character that is
not expected or something.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: script failing at same line

am 04.09.2009 23:05:22 von jim white

$map = ms_newMapObj($mapfile);

The command creates a new mapscript object.

Jay Blanchard wrote:
> [snip]
> I have a script that intermittently fails at the same line. I am trying
> to write some code that will throw an exception after 5 seconds if the
> command on that line fails and the script freezes.
> Any ideas?
> [/snip]
>
> I have lots of ideas! But those really won't help you :)
>
> We need to see the code at that line and be told what is being done in
> order to make a reasonable guess.
>
> My bet is that the data being fed to the script has a character that is
> not expected or something.
>
>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: script failing at same line

am 04.09.2009 23:25:19 von Ben Dunlap

--0016368340d817b2650472c723d5
Content-Type: text/plain; charset=ISO-8859-1

> $map = ms_newMapObj($mapfile);
>
> The command creates a new mapscript object.
>
>
And PHP is hanging somewhere inside that constructor? Is this in a web
context or a command-line context? Or both?

--0016368340d817b2650472c723d5--

Re: script failing at same line

am 04.09.2009 23:38:58 von jim white

It's a web app that draws maps in a browser. Sometime it will generate a
seg fault. The command should not take long, so if there is some script
construct that will throw an exception after a few seconds if the
command has not completed I could signal the user that the map will not
draw and to reload the page.

Jim

Ben Dunlap wrote:
>
> $map = ms_newMapObj($mapfile);
>
> The command creates a new mapscript object.
>
>
> And PHP is hanging somewhere inside that constructor? Is this in a web
> context or a command-line context? Or both?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: script failing at same line

am 05.09.2009 00:17:58 von Ben Dunlap

--000e0cd5cca65c91aa0472c7df34
Content-Type: text/plain; charset=ISO-8859-1

On Fri, Sep 4, 2009 at 2:38 PM, jim white wrote:

> It's a web app that draws maps in a browser. Sometime it will generate a
> seg fault. The command should not take long, so if there is some script
> construct that will throw an exception after a few seconds if the command
> has not completed I could signal the user that the map will not draw and to
> reload the page.


There's a pecl extension called Libevent that can apparently trigger an
action to occur after a certain amount of time has elapsed:

http://us3.php.net/manual/en/ref.libevent.php

I've not used it and have no idea how mature or reliable it is. I'm also
wondering whether any solution will work that relies on the same script
that's about to trigger a segfault.

I think I'd be inclined to build an XHR-based monitor to run in the user's
browser. Even simpler would be to start the map-building process
asynchronously with XHR and then just alert the user, or automatically
refresh the browser, if a certain amount of time elapses before you get a
response from the map-building script. But I don't know how much you'd have
to alter your existing client-side code to use the latter method.

Either way it's creeping away from PHP so maybe I should leave it at that.

Ben

--000e0cd5cca65c91aa0472c7df34--

Re: script failing at same line

am 05.09.2009 02:03:12 von jim white

Hi,

Thanks I'll look at libevent. I have also been thinking about using an
XHR approach, but wonder how passing PHP references works with javascript.

Jim

Ben Dunlap wrote:
> On Fri, Sep 4, 2009 at 2:38 PM, jim white > > wrote:
>
> It's a web app that draws maps in a browser. Sometime it will
> generate a seg fault. The command should not take long, so if
> there is some script construct that will throw an exception after
> a few seconds if the command has not completed I could signal the
> user that the map will not draw and to reload the page.
>
>
> There's a pecl extension called Libevent that can apparently trigger
> an action to occur after a certain amount of time has elapsed:
>
> http://us3.php.net/manual/en/ref.libevent.php
>
> I've not used it and have no idea how mature or reliable it is. I'm
> also wondering whether any solution will work that relies on the same
> script that's about to trigger a segfault.
>
> I think I'd be inclined to build an XHR-based monitor to run in the
> user's browser. Even simpler would be to start the map-building
> process asynchronously with XHR and then just alert the user, or
> automatically refresh the browser, if a certain amount of time elapses
> before you get a response from the map-building script. But I don't
> know how much you'd have to alter your existing client-side code to
> use the latter method.
>
> Either way it's creeping away from PHP so maybe I should leave it at that.
>
> Ben
>
>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: script failing at same line

am 09.09.2009 04:24:24 von jim white

Ben,

My solution was to add a table to my database, and add an insert job id
into the table after the line that is causing the problem. When I submit
the script I use setTimeout to run an AJAX query of the table 5 seconds
later. If the line has failed the job id will not be in the table and I
alert the user. It works - and some day I hope to fix the software
problem and make this unnecessary.

Thanks,
Jim

Ben Dunlap wrote:
> On Fri, Sep 4, 2009 at 2:38 PM, jim white > > wrote:
>
> It's a web app that draws maps in a browser. Sometime it will
> generate a seg fault. The command should not take long, so if
> there is some script construct that will throw an exception after
> a few seconds if the command has not completed I could signal the
> user that the map will not draw and to reload the page.
>
>
> There's a pecl extension called Libevent that can apparently trigger
> an action to occur after a certain amount of time has elapsed:
>
> http://us3.php.net/manual/en/ref.libevent.php
>
> I've not used it and have no idea how mature or reliable it is. I'm
> also wondering whether any solution will work that relies on the same
> script that's about to trigger a segfault.
>
> I think I'd be inclined to build an XHR-based monitor to run in the
> user's browser. Even simpler would be to start the map-building
> process asynchronously with XHR and then just alert the user, or
> automatically refresh the browser, if a certain amount of time elapses
> before you get a response from the map-building script. But I don't
> know how much you'd have to alter your existing client-side code to
> use the latter method.
>
> Either way it's creeping away from PHP so maybe I should leave it at that.
>
> Ben
>
>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: script failing at same line

am 09.09.2009 20:25:32 von Ben Dunlap

--000e0cd5c6ca509e2a04732935a0
Content-Type: text/plain; charset=ISO-8859-1

>
> My solution was to add a table to my database, and add an insert job id
> into the table after the line that is causing the problem. When I submit the
> script I use setTimeout to run an AJAX query of the table 5 seconds later.
> If the line has failed the job id will not be in the table and I alert the
> user. It works - and some day I hope to fix the software problem and make
> this unnecessary.
>

Thanks for the update -- that's about how I would have approached it too.

I wonder, in general, if fixing the underlying problem is even practical or
worth the investment of time. IIRC the problem was in third-party code --
and it seems to me that making your own code robust enough to handle
failures in third-party libraries (as you just did) is a really fruitful use
of your time; fixing the library itself, maybe not so much. I guess it
depends on how it all affects your end users.

Ben

--000e0cd5c6ca509e2a04732935a0--