Phirehose script keeps on running

73 views
Skip to first unread message

d3mon

unread,
Feb 19, 2012, 6:07:43 AM2/19/12
to Phirehose Users
I was using the Phirehose to get the streaming data and the script is
running for infinite time.
set_time_limit was set to 100 but still the feeds were not stopping. I
was writing the feeds into
a text file and using it for other purposes.
The code i used is same as given in sample.php in example folder, is
there any way to stop the same.

Regards
Amit Chhajer

Darren Cook

unread,
Feb 19, 2012, 7:50:23 AM2/19/12
to phireho...@googlegroups.com
> I was using the Phirehose to get the streaming data and the script is
> running for infinite time.
> set_time_limit was set to 100 but still the feeds were not stopping.

set_time_limit uses CPU time, not wall clock time.

If you want a script to run for only 100 seconds, here is one (crude)
way to modify sample.php:

1. At the start of the script, record start time:
$GLOBALS['start_time']=time();

2. In enqueueStatus():
if( (time() - $GLOBALS['start_time']) >100)exit;

(NB. if your script is not receiving much data, it will stop when it
gets the first tweet after having been running for 100 seconds.)

A few ways to make it less crude:
* Use a class var, not a global;

* Consider doing the check in statusUpdate() (or heartbeat()) (though
that only allows you to stop the script once/minute, not after a precise
number of seconds);

* Throw an exception, instead of using exit.

Darren


--
Darren Cook, Software Researcher/Developer

http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)

amit chhajer

unread,
Feb 19, 2012, 8:26:29 AM2/19/12
to phireho...@googlegroups.com
thanks a lot, worked like a charm :)
Reply all
Reply to author
Forward
0 new messages