Execute the batch request

@param int $timeout Request timeout in seconds (optional)

@return  array|false   Assoc array of API response, decoded from JSON
776539
public function execute($timeout = 10)
    {
        $req = array('operations' => $this->operations);

        $result = $this->MailChimp->post('batches', $req, $timeout);

        if ($result && isset($result['id'])) {
            $this->batch_id = $result['id'];
        }

        return $result;
    }
1265529
public function timeout($timeout = null, $connectTimeout = null)
    {
        if(null !== $timeout)
        {
            $this->timeout = $timeout;
        }
        if(null !== $connectTimeout)
        {
            $this->connectTimeout = $connectTimeout;
        }
        return $this;
    }
967610
protected function runStreams($timeout)
    {
        if ($this->readStreams || $this->writeStreams) {
            $read = $this->readStreams;
            $write = $this->writeStreams;
            $except = null;
            if (stream_select($read, $write, $except, (null === $timeout) ? null : 0, $timeout ? (int) ($timeout * 1000000) : 0)) {
                // See PHP Bug https://bugs.php.net/bug.php?id=62452
                // Fixed in PHP7
                foreach ($read as $readStream) {
                    $readCb = $this->readCallbacks[(int) $readStream];
                    $readCb();
                }
                foreach ($write as $writeStream) {
                    $writeCb = $this->writeCallbacks[(int) $writeStream];
                    $writeCb();
                }
            }
        } elseif ($this->running && ($this->nextTick || $this->timers)) {
            usleep(null !== $timeout ? intval($timeout * 1000000) : 200000);
        }
    }
694498
public function connect($timeout = 0.5)
    {
        if (!extension_loaded('swoole'))
        {
            throw new \Exception('swoole extension is required for WebSocketAsync');
        }

        //没有onMessage
        if (!$this->_callback('message'))
        {
            throw new \Exception('no message event callback.');
        }

        $type = SWOOLE_TCP;
        if ($this->ssl)
        {
            $type |= SWOOLE_SSL;
        }

        $this->socket = new \swoole_client($type, SWOOLE_SOCK_ASYNC);
        if ($this->ssl_key_file)
        {
            $this->socket->set(array(
                'ssl_key_file' => $this->ssl_key_file,
                'ssl_cert_file' => $this->ssl_cert_file
            ));
        }

        $this->socket->on("connect", array($this, 'onConnect'));
        $this->socket->on("receive", array($this, 'onReceive'));
        $this->socket->on("error", array($this, 'onError'));
        $this->socket->on("close", array($this, 'onClose'));

        $this->socket->connect($this->host, $this->port, $timeout);
    }
477338
public function setTimeout($timeout)
  {
    // Since this timeout is really for putting a bound on the time
    // we'll set them both to the same. If you need to specify a longer
    // CURLOPT_TIMEOUT, or a higher CONNECTTIMEOUT, the best thing to
    // do is use the setOptions method for the values individually.
    $this->options[CURLOPT_CONNECTTIMEOUT] = $timeout;
    $this->options[CURLOPT_TIMEOUT] = $timeout;
  }
387585
public function select($timeout)
    {
        $read = array($this->socket);
        $write = $except = NULL;

        return stream_select($read, $write, $except, $timeout);
    }
802455
public function setTimeout($timeout)
    {
        curl_setopt($this->curl, CURLOPT_TIMEOUT, $timeout);
        curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT, $timeout);
    }
843668
public function timeout($timeout = null)
    {
        $this->timeout = (null === $timeout) ? $this->defaultTimeout : $timeout;
        return $this;
    }
629536
protected function _receive($timeout = null)
    {
        $this->checkConnection();

        if ($timeout !== null) {
            stream_set_timeout($this->_connection, $timeout);
        }

        $response = fgets($this->_connection, 1024);
        $info = stream_get_meta_data($this->_connection);

        if (!empty($info['timed_out'])) {
            throw new SMTPException(__('%s has timed out', array($this->_host)));
        } elseif ($response === false) {
            throw new SMTPException(__('Could not read from %s', array($this->_host)));
        }

        return $response;
    }
1202132
public static function setTimeout($timeout)
	{
		self::$options[CURLOPT_TIMEOUT] = $timeout;
		self::$options[CURLOPT_CONNECTTIMEOUT] = $timeout;
	}
594408
public function sendAndWait($command, $timeout = 300)
    {
        $commandMessage = $this->wrapCommandWithMessageEnvelope($command);

        // Todo: return future callback and pass it along for dispatching.
        return $this->commandBus->dispatch($commandMessage);
    }
1292402
public function recv($timeout = null)
    {
        // timeout specified?
        if ($timeout !== null) {
            stream_set_timeout($this->socket, $timeout);
        }
        // retrieve response
        $line = fgets($this->socket, 1024);

        if ($this->validationOptions['debug'] === true) {
            $this->debug[] = ["timestamp" => microtime(true), "message" => "received> {$line}"];
        }

        // have we timed out?
        $info = stream_get_meta_data($this->socket);
        if (!empty($info['timed_out'])) {
            throw new Exception\ExceptionTimeout('Timed out in recv');
        }
        // did we actually receive anything?
        if ($line === false) {
            throw new Exception\ExceptionNoResponse('No response in recv');
        }

        return $line;
    }
1057459
public function get($api, $params = [], $timeout = null) {
        $this->prepare($params, $api);
        $url = $this->url . '?' . http_build_query($params);
        curl_setopt($this->curl, CURLOPT_URL, $url);
        curl_setopt($this->curl, CURLOPT_HTTPGET, 1);
        curl_setopt($this->curl, CURLOPT_UPLOAD, false);
        if (is_numeric($timeout) && $timeout) {
            $this->timeout = $timeout;
            curl_setopt($this->curl, CURLOPT_TIMEOUT, $timeout);
        }

        return $this;
    }
115638
public function setTimeout($timeout) {
            $this->timeout = $timeout;
            $this->process->setTimeout($this->timeout);
            return $this;
        }
69480
protected function _receive($timeout = null)
    {
        if (!is_resource($this->_socket)) {
            /**
             * @see Zend_Mail_Protocol_Exception
             */
            // require_once 'Zend/Mail/Protocol/Exception.php';
            throw new Zend_Mail_Protocol_Exception('No connection has been established to ' . $this->_host);
        }

        // Adapters may wish to supply per-commend timeouts according to appropriate RFC
        if ($timeout !== null) {
            $this->_setStreamTimeout($timeout);
        }

        // Retrieve response
        $reponse = fgets($this->_socket, 1024);

        // Save request to internal log
        $this->_addLog($reponse);

        // Check meta data to ensure connection is still valid
        $info = stream_get_meta_data($this->_socket);

        if (!empty($info['timed_out'])) {
            /**
             * @see Zend_Mail_Protocol_Exception
             */
            // require_once 'Zend/Mail/Protocol/Exception.php';
            throw new Zend_Mail_Protocol_Exception($this->_host . ' has timed out');
        }

        if ($reponse === false) {
            /**
             * @see Zend_Mail_Protocol_Exception
             */
            // require_once 'Zend/Mail/Protocol/Exception.php';
            throw new Zend_Mail_Protocol_Exception('Could not read from ' . $this->_host);
        }

        return $reponse;
    }
469444
public static function postCo(array $tasks, $timeout)
    {
        $server = ServerManage::getServer('main')->getSwooleServer();
        $taskParser = TaskParser::getInstance();
        foreach($tasks as $i => $item)
        {
            if(!$item instanceof TaskInfo)
            {
                $task = $taskParser->getTask($item[0]);
                $paramClass = $task['Task']->paramClass;
                $tasks[$i] = new TaskInfo(new $task['className'], new $paramClass($item[1] ?? []));
            }
        }
        $result = $server->taskCo($tasks, $timeout);
        foreach($result as $i => $item)
        {
            call_user_func([$tasks[$i]->getTaskHandler(), 'finish'], $server, -1, $item);
        }
        return $result;
    }
233779
public function block($timeout, $callback = null)
    {
        $starting = time();

        $id = Str::random(20);

        while (! $slot = $this->acquire($id)) {
            if (time() - $timeout >= $starting) {
                throw new LimiterTimeoutException;
            }

            usleep(250 * 1000);
        }

        if (is_callable($callback)) {
            try {
                return tap($callback(), function () use ($slot, $id) {
                    $this->release($slot, $id);
                });
            } catch (Exception $exception) {
                $this->release($slot, $id);

                throw $exception;
            }
        }

        return true;
    }