1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

enh: reset requests.Session feature

Need for proxy changing and other reconnection stuff
This commit is contained in:
uburuntu
2018-09-06 12:42:44 +03:00
parent 2b3c86b647
commit bab9f7bbb9
2 changed files with 6 additions and 7 deletions

View File

@@ -248,13 +248,12 @@ def extract_arguments(text):
return result.group(2) if is_command(text) else None
def per_thread(key, construct_value):
try:
return getattr(thread_local, key)
except AttributeError:
def per_thread(key, construct_value, reset=False):
if reset or not hasattr(thread_local, key):
value = construct_value()
setattr(thread_local, key, value)
return value
return getattr(thread_local, key)
def generate_random_token():