Set the read timeout for the connection. Use 0 to disable timeouts entirely (or use a very long timeout
if not supported).

@param int $timeout 0 (or -1) for no timeout, otherwise number of seconds

@throws RedisException
@return static
514415
public function setReadTimeout(int $timeout)
	{
		if ($timeout < -1) {
			throw new RedisException('Timeout values less than -1 are not accepted.');
		}
		$this->readTimeout = $timeout;
		if ($this->connected) {
			// supported in phpredis 2.2.3
			// a timeout value of -1 means reads will not timeout
			$timeout = $timeout === 0 ? -1 : $timeout;
			$this->redis->setOption(\Redis::OPT_READ_TIMEOUT, $timeout);
		}

		return $this;
	}
1007665
public function setTimeout($timeout) {
        $this->_timeout = (int) $timeout;
        if ( ! is_null($this->_varnishConn)) {
            stream_set_timeout($this->_varnishConn, $this->_timeout);
        }
        return $this;
    }
601519
public function waitReply($timeout = 10) {
        $timestart = time();
        while (true) {
            $char = $this->recvChr();
            $timerun = time() - $timestart;
            if ($timerun >= $timeout) {
                return false;
            }
            if(!empty($char)) {
                return true;
            }
        }
        return false;
    }
188223
public function setTimeout($timeout)
    {
        $timeout = is_scalar($timeout) ? (int) $timeout : 0;

        return $timeout < 1
            ? $this->timeout
            : $this->timeout = $timeout;
    }
290361
public function recover($timeout = 900): void
    {
        $timeoutDate = new \DateTime();
        $timeoutDate->modify(sprintf('-%s seconds', $timeout));

        $str = sprintf('UPDATE %s se SET se.sentAt = null, se.status = :waitStatus, se.statusMessage = null WHERE se.status = :failedStatus AND se.sentAt <= :timeoutDate', $this->getClassName());
        $query = $this->getEntityManager()->createQuery($str)
            ->setParameter('waitStatus', SpoolEmailStatus::STATUS_WAITING)
            ->setParameter('failedStatus', SpoolEmailStatus::STATUS_FAILED)
            ->setParameter('timeoutDate', $timeoutDate)
        ;

        $query->execute();
    }
151221
public function receive($timeout = null)
    {
        if (null == $this->message) {
            try {
                if ($message = $this->doReceive($this->receiveCallback, $this, $timeout)) {
                    $this->message = $message;
                }
            } finally {
                call_user_func($this->finallyCallback, $this);
            }
        }

        return $this->message;
    }
969425
public function setTimeouts($read, $write)
    {
        $this->timeoutRead = $read;
        $this->timeoutWrite = $write;
        if ($this->bev) {
            $this->bev->setTimeouts($this->timeoutRead, $this->timeoutWrite);
        }
    }
1282043
public function setConnectTimeout($connectTimeout) {
        $this->connectTimeout = (float) $connectTimeout;
        if ($this->connectTimeout < 0) {
            throw new InvalidArgumentException('connect timeout < 0');
        }
        return $this;
    }
1046862
public function iterate($timeout)
    {

        // call parent method and sleep for the default timeout
        parent::iterate($timeout);

        // create the requested timer instance
        $this->synchronized(function ($self) {

            // create the timer, only if we're NOT dispatched
            if ($self->dispatched === false) {
                $self->timer = Timer::builder()
                    ->setNewTimer(true)
                    ->setId(Uuid::uuid4()->__toString())
                    ->setInitialDate($self->initialExpiration)
                    ->setRepeatInterval($self->intervalDuration)
                    ->setInfo($self->info)
                    ->setPersistent($self->persistent)
                    ->setTimerState(TimerState::CREATED)
                    ->setTimedObjectId($self->timerService->getTimedObjectInvoker()->getTimedObjectId())
                    ->build($self->timerService);

                // we're dispatched now
                $self->dispatched = true;
            }

        }, $this);

        // profile the size of the sessions
        if ($this->profileLogger) {
            $this->profileLogger->debug(
                sprintf('Size of session pool is: %d', sizeof($this->sessionPool))
            );
        }
    }
1281555
public function setCommandTimeout($commandTimeout)
    {
        if ($commandTimeout !== null && ! is_numeric($commandTimeout)) {
            throw new InvalidArgumentException('Timeout must be an integer.');
        }

        if (is_string($commandTimeout)) {
            $commandTimeout = (int) $commandTimeout;
        }

        $this->commandTimeout = $commandTimeout;

        return $this;
    }
506203
public static function unblock($lock, $timeout = 5) {
        try {
            $redis = RedisClient::getRedis();
            if ($redis) {
                $cnt = $redis->incr($lock);
                if ($cnt == 1) {
                    $redis->setTimeout($lock, $timeout);//设置超时，防止死锁

                    return true;
                }
            }
        } catch (\Exception $e) {
            log_warn($e->getMessage(), 'redis_lock');
        }

        return false;
    }
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;
    }
770448
public function stop(float $timeout = 0.0): self
    {
        if ($this->lastKey !== null) {
            $this->set($this->lastKey, ob_get_clean(), $timeout);
        }
        $this->lastKey = null;
        return $this;
    }
927368
public void setConnectTimeout(int timeout) {
		Assert.isTrue(timeout >= 0, "Timeout must be a non-negative value");
		getHttpClient().getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout);
	}
1144692
public void setSoTimeout(int timeout) throws SocketException{
      super.setSoTimeout(timeout);
      if(!doing_direct) proxy.proxySocket.setSoTimeout(timeout);
   }
417415
public function timeout($timeout = null)
    {
        // Return value
        if (empty($timeout)) {
            return $this->timeout;
        }

        // Set value
        $this->timeout = $timeout;

        return $this;
    }
223068
public function setTimeout($timeout)
    {
        if (null === $timeout) {
            $this->timeout = null;

            return $this;
        }

        $timeout = (float) $timeout;

        if ($timeout < 0) {
            throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
        }

        $this->timeout = $timeout;

        return $this;
    }