Method to set the connection and request timeouts by reading from the configuration file or Context object
346269
private RequestConfig setTimeout(Context context) {
        int socketTimeout = 0;
        int connectionTimeout = 0;
        if ( context.getCustomerRequestTimeout() != null) {
            socketTimeout = context.getCustomerRequestTimeout();
        }else {
            String reqTimeout = Config.getProperty(Config.TIMEOUT_REQUEST);
            if (StringUtils.hasText(reqTimeout)) {
                socketTimeout = new Integer(reqTimeout.trim());
            }
        }

        String connTimeout = Config.getProperty(Config.TIMEOUT_CONNECTION);
        if (StringUtils.hasText(connTimeout)) {
            connectionTimeout = new Integer(connTimeout.trim());
        }
        RequestConfig defaultRequestConfig = RequestConfig.custom()
                .setSocketTimeout(socketTimeout)
                .setConnectTimeout(connectionTimeout)
                .setConnectionRequestTimeout(connectionTimeout)
                .setCookieSpec(CookieSpecs.IGNORE_COOKIES)
                .build();
        return defaultRequestConfig;

    }
1207674
public void setTimeout(int timeout) {
        if (config.delivery instanceof HttpDelivery) {
            ((HttpDelivery) config.delivery).setTimeout(timeout);
        }
        if (config.sessionDelivery instanceof HttpDelivery) {
            ((HttpDelivery) config.sessionDelivery).setTimeout(timeout);
        }
    }
898810
private void applyPoolConfiguration(PoolConfiguration pc,
                                       org.ironjacamar.common.api.metadata.common.Timeout t)
   {
      if (t != null)
      {
         if (t.getBlockingTimeoutMillis() != null)
            pc.setBlockingTimeout(t.getBlockingTimeoutMillis().longValue());
         
         if (t.getIdleTimeoutMinutes() != null)
            pc.setIdleTimeoutMinutes(t.getIdleTimeoutMinutes().intValue());
      }
   }
182938
public void setContextPath(String contextPathSpec)
    {
        if (_httpServer!=null)
            _httpServer.removeMappings(this);

        contextPathSpec=canonicalContextPathSpec(contextPathSpec);

        if (contextPathSpec.length()>1)
            _contextPath=contextPathSpec.substring(0,contextPathSpec.length()-2);
        else
            _contextPath="/";

        _contextName=null;

        if (_httpServer!=null)
            _httpServer.addMappings(this);
    }
305594
public void setConnectTimeout(int millis) {
		ClientHttpRequestFactory f = getRequestFactory();
		if (f instanceof SimpleClientHttpRequestFactory) {
			((SimpleClientHttpRequestFactory) f).setConnectTimeout(millis);
		}
		else {
			((HttpComponentsClientHttpRequestFactory) f).setConnectTimeout(millis);
		}
	}
226697
private void connect() {
        try {
            URL url = new URL(this.endpoint);
            connection = (HttpURLConnection) url.openConnection();
            connection.setReadTimeout(this.readTimeoutMs);
            connection.setConnectTimeout(this.connectTimeoutMs);
            connection.setRequestMethod(this.method.name());
            if (method == HttpMethod.POST || method == HttpMethod.PUT) {
                connection.setDoOutput(true);
            } else {
                connection.setDoOutput(false);
            }
            connection.setDoInput(true);
            connection.setUseCaches(false);
            for (String headerName : headers.keySet()) {
                String headerValue = headers.get(headerName);
                connection.setRequestProperty(headerName, headerValue);
            }
            connection.connect();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
268320
public void connect(SocketAddress endpoint, int timeout) throws IOException {
    String filename;
    if (host == null || host.equals("localhost")) {
      filename = "\\\\.\\pipe\\" + name;
    } else {
      filename = "\\\\" + host + "\\pipe\\" + name;
    }

    //use a default timeout of 100ms if no timeout set.
    int usedTimeout = timeout == 0 ? 100 : timeout;
    long initialNano = System.nanoTime();
    do {
      try {
        file = new RandomAccessFile(filename, "rw");
        break;
      } catch (FileNotFoundException fileNotFoundException) {
        try {
          //using JNA if available
          Kernel32.INSTANCE.WaitNamedPipe(filename, timeout);
          //then retry connection
          file = new RandomAccessFile(filename, "rw");
        } catch (Throwable cle) {
          // in case JNA not on classpath, then wait 10ms before next try.
          if (System.nanoTime() - initialNano > TimeUnit.MILLISECONDS.toNanos(usedTimeout)) {
            if (timeout == 0) {
              throw new FileNotFoundException(fileNotFoundException.getMessage()
                  + "\nplease consider set connectTimeout option, so connection can retry having access to named pipe. "
                  + "\n(Named pipe can throw ERROR_PIPE_BUSY error)");
            }
            throw fileNotFoundException;
          }
          try {
            TimeUnit.MILLISECONDS.sleep(5);
          } catch (InterruptedException interrupted) {
            IOException ioException = new IOException(
                "Interruption during connection to named pipe");
            ioException.initCause(interrupted);
            throw ioException;
          }
        }
      }
    } while (true);

    is = new InputStream() {
      @Override
      public int read(byte[] bytes, int off, int len) throws IOException {
        return file.read(bytes, off, len);
      }

      @Override
      public int read() throws IOException {
        return file.read();
      }

      @Override
      public int read(byte[] bytes) throws IOException {
        return file.read(bytes);
      }
    };

    os = new OutputStream() {
      @Override
      public void write(byte[] bytes, int off, int len) throws IOException {
        file.write(bytes, off, len);
      }

      @Override
      public void write(int value) throws IOException {
        file.write(value);
      }

      @Override
      public void write(byte[] bytes) throws IOException {
        file.write(bytes);
      }
    };
  }
687421
public void setConnectionTimeout(long connectionTimeout, TimeUnit timeUnit) {
		this.connectionTimeoutInMs = TimeUnit.MILLISECONDS.convert(connectionTimeout, timeUnit);
	}
631655
def _handle_request_exc(exc, retry_timeout_config):
    
    if isinstance(exc, requests.exceptions.ConnectTimeout):
        raise ConnectTimeout(_request_exc_message(exc), exc,
                             retry_timeout_config.connect_timeout,
                             retry_timeout_config.connect_retries)
    elif isinstance(exc, requests.exceptions.ReadTimeout):
        raise ReadTimeout(_request_exc_message(exc), exc,
                          retry_timeout_config.read_timeout,
                          retry_timeout_config.read_retries)
    elif isinstance(exc, requests.exceptions.RetryError):
        raise RetriesExceeded(_request_exc_message(exc), exc,
                              retry_timeout_config.connect_retries)
    else:
        raise ConnectionError(_request_exc_message(exc), exc)
1092748
private void timeoutHasExpired(final Timeout timeout, final TimeoutExpirationContext context) {
        try {
            addMessage(timeout, context.getOriginalHeaders());
        } catch (Exception ex) {
            LOG.error("Error handling timeout {}", timeout, ex);
        }
    }
1255766
@Override
	public void setConnectionTimeoutMS(int connectionTimeoutMS) {
    	connectionManager.getParams().setConnectionTimeout(connectionTimeoutMS);
    	http.getParams().setConnectionManagerTimeout(connectionTimeoutMS);
	}
1361603
private void setTimeout(HttpURLConnection httpUrlConnection) {
		String connTimeout = Config.getProperty(Config.TIMEOUT_CONNECTION);
		if (StringUtils.hasText(connTimeout)) {
			httpUrlConnection.setReadTimeout(new Integer(connTimeout.trim()));			
		}
		String reqTimeout = Config.getProperty(Config.TIMEOUT_REQUEST);
		if (StringUtils.hasText(reqTimeout)) {
			httpUrlConnection.setConnectTimeout(new Integer(reqTimeout.trim()));			
		}
	}
285519
private void timeoutExpired(final Timeout timeout, final TimeoutContext context) {
        try {
            removeExpiredTimeout(timeout);

            for (TimeoutExpired callback : callbacks) {
                if (callback instanceof TimeoutExpirationCallback) {
                    ((TimeoutExpirationCallback) callback).expired(timeout, context);
                } else {
                    callback.expired(timeout);
                }
            }
        } catch (Exception ex) {
            // catch all exceptions. otherwise calling timeout thread of timers thread pool will be terminated.
            LOG.error("Error handling timeout.", ex);
        }
    }
1314400
private void setupConnection(final Connection connection) throws ConnectionSetupException
   {
      try {
         if (networkTimeout == UNINITIALIZED) {
            networkTimeout = getAndSetNetworkTimeout(connection, validationTimeout);
         }
         else {
            setNetworkTimeout(connection, validationTimeout);
         }

         if (connection.isReadOnly() != isReadOnly) {
            connection.setReadOnly(isReadOnly);
         }

         if (connection.getAutoCommit() != isAutoCommit) {
            connection.setAutoCommit(isAutoCommit);
         }

         checkDriverSupport(connection);

         if (transactionIsolation != defaultTransactionIsolation) {
            connection.setTransactionIsolation(transactionIsolation);
         }

         if (catalog != null) {
            connection.setCatalog(catalog);
         }

         if (schema != null) {
            connection.setSchema(schema);
         }

         executeSql(connection, config.getConnectionInitSql(), true);

         setNetworkTimeout(connection, networkTimeout);
      }
      catch (SQLException e) {
         throw new ConnectionSetupException(e);
      }
   }
911258
def insert(self, context):
	
		
		
		status_code, msg = self.__endpoint.post(
			"/resources/connector-connection-pool",
			data={
				"id": self.__name,
				"resourceAdapterName": self.__res_adapter_name,
				"connectiondefinitionname": self.__conn_def_name,
				"property": props_value(self.__props)
			}
		)
		self.__available = True
973227
@Override
    public String invoke(Object connection, String request, int timeout, Map<String,String> metainfo)
    throws ConnectionException, AdapterException {
        String response;
        try{
            if (timeout<=0) timeout = DEFAULT_TIMEOUT;
            SoccomClient client = (SoccomClient)connection;
            client.putreq(request);
            response = client.getresp(timeout);
        } catch (SoccomException ex){
            if (ex.getErrorCode()==SoccomException.POLL_TIMEOUT)
                throw new ConnectionException(ConnectionException.CONNECTION_DOWN, ex.getMessage(), ex);
            else throw new AdapterException(-1, ex.getMessage(), ex);
        }
        return response;
    }
888890
def request(self, method, url, **kwargs):
        
        if 'timeout' not in kwargs:
            if self.timeout is not None:
                kwargs['timeout'] = self.timeout
            else:
                kwargs['timeout'] = (DEFAULT_CONNECT_TIMEOUT,
                                     DEFAULT_READ_TIMEOUT)
        return super(Session, self).request(method=method, url=url, **kwargs)