Re: [PHP] script failing at same line
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
Re: [PHP] script failing at same line
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 jbw2...@earthlink.net mailto:jbw2...@earthlink.net 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: [PHP] script failing at same line
[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: [PHP] script failing at same line
$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: [PHP] script failing at same line
$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?
Re: [PHP] script failing at same line
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: [PHP] script failing at same line
On Fri, Sep 4, 2009 at 2:38 PM, jim white jbw2...@earthlink.net 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
Re: [PHP] script failing at same line
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 jbw2...@earthlink.net mailto:jbw2...@earthlink.net 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