Skip to content

Commit a27b768

Browse files
committed
Use env variable for requests pool
1 parent b657ae0 commit a27b768

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

twExtract/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
userByRestIdGraphql_api="8r5oa_2vD0WkhIAOkY4TTA"
4848

4949
twitterUrl = "x.com" # doubt this will change but just in case
50+
51+
simultaneousRequests = int(os.getenv("VXTWITTER_SIMULTANEOUS_REQUESTS",1))
52+
5053
class TwExtractError(Exception):
5154
def __init__(self, code, message):
5255
self.code = code
@@ -65,7 +68,7 @@ def try_token(token):
6568
except Exception as e:
6669
return {'success': False, 'error': str(e)}
6770

68-
with concurrent.futures.ThreadPoolExecutor(max_workers=min(2, len(tokens))) as executor:
71+
with concurrent.futures.ThreadPoolExecutor(max_workers=min(simultaneousRequests, len(tokens))) as executor:
6972
futures = {executor.submit(try_token, token): token for token in tokens}
7073
for future in concurrent.futures.as_completed(futures):
7174
result = future.result()

0 commit comments

Comments
 (0)