public static function pushCaliperEvents($seconds=3, $max=100, $debug=false) {
        // Remove broken events
        $purged = self::purgeCaliperEvents();

        $start = time();
        $count = 0;
        $now = $start;
        $end = $start + $seconds;
        $failure = 0;
        $failure_code = false;
        $retval = array();
        if ( U::apcAvailable() ) {
            $found = false;
            $last_push = apc_fetch('last_event_push_time',$found);
            $diff = $start - $last_push;
            if ( $found && $diff < self::PUSH_REPEAT_SECONDS ) {
                // error_log("Last push was $diff seconds ago");
                $retval['count'] = $count;
                $retval['fail'] = $failure;
                $retval['failcode'] = 999;
                $retval['seconds'] = 0;
                $retval['purged'] = $purged;
                return $retval;
            }
            apc_store('last_event_push_time',$start);
        }

        while ($count < $max && $now < $end ) {
            $result = self::sendCaliperEvent(!$debug);
            if ( $debug ) {
                echo("\nResults of sendCaliperEvent:\n");
                echo(U::safe_var_dump($result));
            }
            if ( $result === false ) break;

            if ( $result['code'] != 200 ) {
                $failure++;
                if ( $failure_code === false ) $failure_code = $result['code'];
            }
            $count++;
            $now = time();
            $delta = $now - $start;
        }

        $now = time();
        $delta = $now - $start;
        $retval['count'] = $count;
        $retval['fail'] = $failure;
        if ( $failure_code !== false ) $retval['failcode'] = $failure_code;
        $retval['seconds'] = $delta;
        $retval['purged'] = $purged;
        return $retval;
    }