Skip to content

Commit

Permalink
session connection
Browse files Browse the repository at this point in the history
  • Loading branch information
nextcaptcha committed Jul 18, 2024
1 parent b69eae8 commit a57e13e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,5 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
.idea/
test.py
2 changes: 1 addition & 1 deletion nextcaptcha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@



__version__ = '1.0.6'
__version__ = '1.0.7'
11 changes: 10 additions & 1 deletion nextcaptcha/next.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import time

from urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter
import requests

logging.basicConfig(level=logging.INFO)
Expand Down Expand Up @@ -39,6 +40,14 @@ def __init__(self, client_key: str, solft_id: str, callback_url: str, open_log:
self.open_log = open_log
self.session = requests.session()


adapter = HTTPAdapter(pool_connections=1000, pool_maxsize=1000)
retries = Retry(total=5, backoff_factor=1, status_forcelist=[502, 503, 504])
self.session.mount('http://', adapter)
self.session.mount('https://', adapter)
self.session.mount('http://', HTTPAdapter(max_retries=retries))
self.session.mount('https://', HTTPAdapter(max_retries=retries))

def _get_balance(self) -> str:
resp = self.session.post(url=self.HOST + "/getBalance", json={"clientKey": self.client_key})
if resp.status_code != 200:
Expand Down

0 comments on commit a57e13e

Please sign in to comment.