Skip to content

Commit

Permalink
Receive a custom Session instance
Browse files Browse the repository at this point in the history
  • Loading branch information
burnash committed Feb 19, 2024
1 parent 0ea0edb commit 16c5a7a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sources/rest_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import copy

from requests.auth import AuthBase
from requests import Session as BaseSession


from dlt.common import logger
from dlt.sources.helpers import requests
from dlt.sources.helpers.requests import client

from .paginators import BasePaginator, UnspecifiedPaginator
from .detector import create_paginator
Expand All @@ -29,10 +31,12 @@ def __init__(
headers: Optional[Dict[str, str]] = None,
auth: Optional[AuthBase] = None,
paginator: Optional[BasePaginator] = None,
session: BaseSession = None
) -> None:
self.base_url = base_url
self.headers = headers
self.auth = auth
self.session = session or client.session
self.paginator = paginator if paginator else UnspecifiedPaginator()

def make_request(self, path="", method="get", params=None, json=None):
Expand All @@ -46,7 +50,7 @@ def make_request(self, path="", method="get", params=None, json=None):
f"json={json}"
)

response = requests.request(
response = self.session.request(
method=method,
url=url,
headers=self.headers,
Expand Down

0 comments on commit 16c5a7a

Please sign in to comment.