diff --git a/doc/ReferenceOfClasses.md b/doc/ReferenceOfClasses.md index 5bab56dc..b82d109e 100644 --- a/doc/ReferenceOfClasses.md +++ b/doc/ReferenceOfClasses.md @@ -18,6 +18,7 @@ Constructed from user's login and password or OAuth token or nothing: g = Github() You can add an argument `base_url = "http://my.enterprise.com:8080/path/to/github"` to connect to a local install of Github (ie. Github Enterprise). +Another argument, that can be passed is `timeout` which has default value `10`. Attributes ---------- diff --git a/github/Github.py b/github/Github.py index 360ae0eb..e34204a2 100644 --- a/github/Github.py +++ b/github/Github.py @@ -24,10 +24,11 @@ import Legacy import GithubObject DEFAULT_BASE_URL = "https://api.github.com" +DEFAULT_TIMEOUT = 10 class Github( object ): - def __init__( self, login_or_token = None, password = None, base_url = DEFAULT_BASE_URL ): - self.__requester = Requester( login_or_token, password, base_url ) + def __init__( self, login_or_token = None, password = None, base_url = DEFAULT_BASE_URL, timeout = DEFAULT_TIMEOUT): + self.__requester = Requester( login_or_token, password, base_url, timeout ) @property def rate_limiting( self ): diff --git a/github/Requester.py b/github/Requester.py index be96e597..680ed417 100644 --- a/github/Requester.py +++ b/github/Requester.py @@ -32,7 +32,7 @@ class Requester: cls.__httpConnectionClass = httpConnectionClass cls.__httpsConnectionClass = httpsConnectionClass - def __init__( self, login_or_token, password, base_url ): + def __init__( self, login_or_token, password, base_url, timeout ): if password is not None: login = login_or_token self.__authorizationHeader = "Basic " + base64.b64encode( login + ":" + password ).replace( '\n', '' ) @@ -47,13 +47,13 @@ class Requester: self.__hostname = o.hostname self.__port = o.port self.__prefix = o.path + self.__timeout = timeout if o.scheme == "https": self.__connectionClass = self.__httpsConnectionClass elif o.scheme == "http": self.__connectionClass = self.__httpConnectionClass else: assert( False ) #pragma no cover - self.rate_limiting = ( 5000, 5000 ) def requestAndCheck( self, verb, url, parameters, input ): @@ -79,7 +79,7 @@ class Requester: if self.__authorizationHeader is not None: headers[ "Authorization" ] = self.__authorizationHeader - cnx = self.__connectionClass( host = self.__hostname, port = self.__port, strict = True ) + cnx = self.__connectionClass( host = self.__hostname, port = self.__port, strict = True, timeout= self.__timeout ) cnx.request( verb, self.__completeUrl( url, parameters ),