-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
34 lines (24 loc) · 1.15 KB
/
Copy pathconfig.py
File metadata and controls
34 lines (24 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Configuration for the Threads Scraper. Everything can be set with an
environment variable; the defaults work out of the box.
PORT port the API listens on (default 8000)
THREADS_PROXY proxy URL for every request, e.g. http://user:pass@host:port
(default: none — direct). threads.com answered 30
back-to-back requests from one IP without a single block,
so you very likely don't need this. Set it only if you
start seeing failures at high volume.
Everything else below is a plain constant with a working default — edit it
here if you need to.
"""
import os
PORT = int(os.environ.get("PORT", "8000"))
# Retry policy for transport errors and blocks (every request).
MAX_RETRIES = 3
RETRY_BACKOFF = 2 # seconds, multiplied by the attempt number
THREADS_PROXY = os.environ.get("THREADS_PROXY") or None
# No automatic fallback exit here: a blocked request is simply retried.
THREADS_FALLBACK_PROXY_COUNTRY = None
THREADS_DIRECT_COOLDOWN = 900
def threads_proxy():
return os.environ.get("THREADS_PROXY") or None
def threads_fallback_proxy():
return None