@@ -18,6 +18,7 @@ def __init__(self, **kwargs):
1818 self ._username = kwargs .get ('username' , None )
1919 self ._password = kwargs .get ('password' , None )
2020 self ._strategy = kwargs .get ('strategy' , None )
21+ self ._timeout = kwargs .pop ('timeout' , (5.0 , 10.0 ))
2122
2223 def login (self ):
2324 self ._session .headers = {
@@ -30,12 +31,12 @@ def login(self):
3031 'Origin' : self .BASE_URL ,
3132 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8' ,
3233 }
33- self ._session .get (self .BASE_URL )
34+ self ._session .get (self .BASE_URL , timeout = self . _timeout )
3435 response = self ._session .post ('{}/usermaster/authenticate/v1.json' .format (self .BASE_URL ), data = {
3536 'username' : self ._username ,
3637 'password' : self ._password ,
3738 'rememberMe' : 'false'
38- })
39+ }, timeout = self . _timeout )
3940 self ._session .headers .update ({
4041 'cookie' : response .headers ['Set-Cookie' ]
4142 })
@@ -44,9 +45,10 @@ def login(self):
4445
4546 def query (self ):
4647 today_str = datetime .today ().strftime ('%Y-%m-%d' )
47- response = self ._session .get ('{}/mercury_trade/strategy/{}/order' .format (self .BASE_URL , self ._strategy ), params = {
48- 'date' : today_str ,
49- })
48+ response = self ._session .get ('{}/mercury_trade/strategy/{}/order' .format (self .BASE_URL , self ._strategy ),
49+ params = {
50+ 'date' : today_str ,
51+ }, timeout = self ._timeout )
5052 raw_transactions = response .json ()
5153 transactions = []
5254 for raw_transaction in raw_transactions :
0 commit comments