NYCPHP Meetup

NYPHP.org

[nycphp-talk] php script timeout not working

Corey H Maass - gelform.com corey at gelform.com
Mon Apr 6 20:29:18 EDT 2009


Okay, trying curl. Using:

$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://localhost/uploader');
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_exec($curl_handle);
curl_close($curl_handle);

But it doesn't timeout. Any ideas?

Thanks,

Corey

On Mon, 6 Apr 2009 14:27:26 -0400, "Brent Baisley" <brenttech at gmail.com>
said:
> wget or curl basically hit a web page. One of the parameters is a URL
> to hit, you're just not using a browser. Although you could tell the
> server you are a browser of your choice.
> 
> Brent Baisley
> 
> On Mon, Apr 6, 2009 at 2:01 PM, Corey H Maass - gelform.com
> <corey at gelform.com> wrote:
> > Interesting. I'll take a look at wget. I do need to pass a param so I do
> > need to run it as a URL I think.
> >
> > Corey
> >
> > On Mon, 6 Apr 2009 12:02:33 -0400, "Brent Baisley" <brenttech at gmail.com>
> > said:
> >> It's fairly easy to convert a PHP script to an executable script under
> >> Unix. Just make it executable. Most things work without changes,
> >> although you will be missing any URL parameters and web specific
> >> directives. I've used parts of the Zend framework in command line
> >> scripts without changes.
> >> But if you really need to keep it as a web page, use wget as the exec
> >> script. It's round about, but you are running and releasing the script
> >> while keeping it web based.
> >> Although for php to call the script and not wait for it to complete, I
> >> think you need to do more than just put it in the background. You have
> >> to make sure PHP has no return values to wait for (>/dev/null 2>&1)
> >> and "gives up" control of it (nohup)
> >> shell_exec('nohup wget ... > /dev/null 2>&1)
> >>
> >> Brent Baisley
> >>
> >> On Mon, Apr 6, 2009 at 10:53 AM, Corey H Maass - gelform.com
> >> <corey at gelform.com> wrote:
> >> > Thanks, Rob. I looked at that for a minute cos it seems like the best
> >> > option, but I'm using the Zend framework, where it would be a pain to
> >> > break the code out to be an executable script. Plus I want to be able to
> >> > call it from a URL.
> >> >
> >> > Corey
> >> >
> >> > On Sun, 5 Apr 2009 18:51:44 -0400, "Rob Marscher"
> >> > <rmarscher at beaffinitive.com> said:
> >> >> Corey,
> >> >> Are you on a unix based machine?  Is that script really local?
> >> >>
> >> >> Try
> >> >> shell_exec('/path/to/s3uploader.php &');
> >> >> instead of fopen.
> >> >>
> >> >> The ampersand will get it to return without waiting for the upload
> >> >> script to finish.
> >> >>
> >> >> On Apr 5, 2009, at 6:16 PM, Daniel Convissor
> >> >> <danielc at analysisandsolutions.com
> >> >>  > wrote:
> >> >>
> >> >> > Hi Corey:
> >> >> >
> >> >> > On Sun, Apr 05, 2009 at 04:28:20PM -0400, Corey H Maass -
> >> >> > gelform.com wrote:
> >> >> >>
> >> >> >> set_time_limit(1);
> >> >> >
> >> >> > set_time_limit() works for your PHP code.  Streams, in a way, are
> >> >> > outside
> >> >> > your PHP code.
> >> >> >
> >> >> >
> >> >> >> $handle = fopen("http://localhost/s3uploader.php", "r");
> >> >> >> stream_set_timeout($handle, 1);
> >> >> >>
> >> >> >> But neither timeout is working - it sits and spins while the upload
> >> >> >> takes place. Any ideas?
> >> >> >
> >> >> > That's not working because you're opening and reading the file
> >> >> > directly.
> >> >> > The timeout setting has no effect because you haven't gotten to that
> >> >> > line
> >> >> > yet
> >> >> >
> >> >> > Two options.  Use fsockopen() instead of fopen(), see the
> >> >> > stream_set_timeout() documentation for examples.  Or use
> >> >> > ini_set('default_socket_timeout', 1) before you call fopen().
> >> >> >
> >> >> > --Dan
> >> >> >
> >> >> > --
> >> >> > T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
> >> >> >            data intensive web and database programming
> >> >> >                http://www.AnalysisAndSolutions.com/
> >> >> > 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409
> >> >> > _______________________________________________
> >> >> > New York PHP User Group Community Talk Mailing List
> >> >> > http://lists.nyphp.org/mailman/listinfo/talk
> >> >> >
> >> >> > http://www.nyphp.org/show_participation.php
> >> >> _______________________________________________
> >> >> New York PHP User Group Community Talk Mailing List
> >> >> http://lists.nyphp.org/mailman/listinfo/talk
> >> >>
> >> >> http://www.nyphp.org/show_participation.php
> >> >
> >> > //
> >> > Corey H Maass
> >> > Gelform Design
> >> > Brooklyn, NY
> >> > Web design and development for art and business
> >> >
> >> > em corey at gelform.com
> >> > ww http://www.gelform.com
> >> > ph 646/228.5048
> >> > fx 866/502.4861
> >> > IM gelform
> >> >
> >> > _______________________________________________
> >> > New York PHP User Group Community Talk Mailing List
> >> > http://lists.nyphp.org/mailman/listinfo/talk
> >> >
> >> > http://www.nyphp.org/show_participation.php
> >> >
> >> _______________________________________________
> >> New York PHP User Group Community Talk Mailing List
> >> http://lists.nyphp.org/mailman/listinfo/talk
> >>
> >> http://www.nyphp.org/show_participation.php
> >
> > //
> > Corey H Maass
> > Gelform Design
> > Brooklyn, NY
> > Web design and development for art and business
> >
> > em corey at gelform.com
> > ww http://www.gelform.com
> > ph 646/228.5048
> > fx 866/502.4861
> > IM gelform
> >
> > _______________________________________________
> > New York PHP User Group Community Talk Mailing List
> > http://lists.nyphp.org/mailman/listinfo/talk
> >
> > http://www.nyphp.org/show_participation.php
> >
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
> 
> http://www.nyphp.org/show_participation.php

//
Corey H Maass
Gelform Design
Brooklyn, NY
Web design and development for art and business

em corey at gelform.com
ww http://www.gelform.com
ph 646/228.5048
fx 866/502.4861
IM gelform




More information about the talk mailing list