Browse Source

6.0.1: Speed things up with a requests session

master 6.0.1
SporeStack 2 months ago
parent
commit
f62bfa0568
  1. 2
      setup.cfg
  2. 9
      src/sporestack/api_client.py

2
setup.cfg

@ -1,6 +1,6 @@
[metadata]
name = sporestack
version = 6.0.0
version = 6.0.1
description = SporeStack.com library and client. Launch servers with Monero or Bitcoin.
long_description = file: README.md
long_description_content_type = text/markdown

9
src/sporestack/api_client.py

@ -24,6 +24,9 @@ POST_TIMEOUT = 90
USE_TOR_PROXY = "auto"
session = requests.Session()
def _get_tor_proxy() -> str:
"""
This makes testing easier.
@ -70,15 +73,15 @@ def _api_request(
try:
if empty_post is True:
request = requests.post(
request = session.post(
url, timeout=POST_TIMEOUT, proxies=proxies, headers=headers
)
elif json_params is None:
request = requests.get(
request = session.get(
url, timeout=GET_TIMEOUT, proxies=proxies, headers=headers
)
else:
request = requests.post(
request = session.post(
url,
json=json_params,
timeout=POST_TIMEOUT,

Loading…
Cancel
Save