Maximum execution time using filter-track

117 views
Skip to first unread message

Antonio Max

unread,
Feb 3, 2010, 10:48:39 AM2/3/10
to Phirehose Users
Plain simple:

<?php
require_once('../lib/Phirehose.php');

class FilterTrackConsumer extends Phirehose
{
public function enqueueStatus($status)
{
$data = json_decode($status, true);
if (is_array($data) && isset($data['user']['screen_name'])) {
print $data['user']['screen_name'] . ': ' . urldecode($data
['text']) . "\n";
}
}
}

// Start streaming
$sc = new FilterTrackConsumer('usr', 'pwd', Phirehose::METHOD_FILTER);
$sc->setTrack(array('sushi', 'japan'));
$sc->consume();
?>

Just doesn´t work for me, on any server i just get the:
Fatal error: Maximum execution time of 200 seconds exceeded in D:\xampp
\htdocs\phirehouse\lib\Phirehose.php on line 467

What am I doing wrong here?
Thanks!

Fenn

unread,
Feb 3, 2010, 7:21:45 PM2/3/10
to Phirehose Users
Hi Antonio,

Good question - I think this is tripping up a few people. The core
point to understand is that long running streaming processes (like
Phirehose) should not be run as part of a webpage. Although PHP was
originally designed for displaying web pages, you need to be familiar
with running PHP command-line applications and making them run in the
background (essentially forever), unlike a webpage that is supposed to
"run" in under a second and then stops.

From the docs:
"Please note that this library is only intended to work in a CLI
environment (not embedded in a web-script and run by your webserver)
and will likely require some form of multi-processing (either
pcntl_fork() or entirely separate processes and some knowledge of how
multi-processing works on your and your hosting providers operating
systems). See below for more details."

You can find some help on this here: http://www.php-cli.com/ and here:
http://php.net/manual/en/features.commandline.php

Good luck!

Fenn.

Thomas

unread,
Feb 7, 2010, 3:46:14 AM2/7/10
to Phirehose Users
On Feb 3, 4:48 pm, Antonio Max <antonio...@gmail.com> wrote:
> Just doesn´t work for me, on any server i just get the:
> Fatal error: Maximum execution time of 200 seconds exceeded in D:\xampp
> \htdocs\phirehouse\lib\Phirehose.php  on line 467

As Fenn already mentioned, you must split gathering and analysis in
two processes. Gathering refers to storing Twitter's data stream on
your system in a background process. Analysis refers to any following
processing, e.g. counting, grouping and of course displaying. From my
experience, Fenn's example of queuing from 0.21 is a great start.
Currently, I'm around 1000 tweets per minute and my virtual servers
runs perfectly. Analysis will be done on a second virtual server to
prevent any interruptions.

Thomas

Reply all
Reply to author
Forward
0 new messages