@@ -109,12 +109,7 @@ def __init__(self, schema: StructType, options: Dict):
109109 raise ValueError (f"Invalid private key format: { str (e )} " )
110110
111111
112-
113- # Initialize session for connection pooling
114- self .session = requests .Session ()
115- self .session .headers .update ({
116- 'User-Agent' : 'PySpark Robinhood Crypto DataSource/1.0'
117- })
112+
118113
119114 # Crypto API base URL
120115 self .base_url = "https://trading.robinhood.com"
@@ -153,18 +148,18 @@ def _make_authenticated_request(self, method: str, path: str, params: Dict = Non
153148 headers = {
154149 'x-api-key' : self .api_key ,
155150 'x-signature' : signature ,
156- 'x-timestamp' : str (timestamp ),
151+ 'x-timestamp' : str (timestamp )
157152 }
158153
159154 try :
160155 # Make request
161156 if method .upper () == "GET" :
162- response = self . session .get (url , headers = headers , params = params , timeout = 10 )
157+ response = requests .get (url , headers = headers , params = params , timeout = 10 )
163158 elif method .upper () == "POST" :
164159 headers ['Content-Type' ] = 'application/json'
165- response = self . session .post (url , headers = headers , json = json_data , timeout = 10 )
160+ response = requests .post (url , headers = headers , json = json_data , timeout = 10 )
166161 else :
167- response = self . session .request (method , url , headers = headers , params = params , json = json_data , timeout = 10 )
162+ response = requests .request (method , url , headers = headers , params = params , json = json_data , timeout = 10 )
168163
169164 response .raise_for_status ()
170165 return response .json ()
0 commit comments