Prevented multisend

This commit is contained in:
Pünkösd Marcell 2021-12-12 19:07:17 +01:00
parent d71987db7e
commit 0ea6b8c69b

View File

@ -8,6 +8,7 @@ from .abcsender import AbcSender
from utils import config, LoopingTimer from utils import config, LoopingTimer
from urllib.parse import urljoin from urllib.parse import urljoin
import time import time
from threading import Lock
""" """
Send a sound sample Send a sound sample
@ -24,6 +25,8 @@ class SoundSender(AbcSender):
SoundSender class, responsible for sending sound samples to the cloud. SoundSender class, responsible for sending sound samples to the cloud.
""" """
super_global_multi_sender_preventer = Lock()
def __init__(self): def __init__(self):
self._feed_url = None self._feed_url = None
@ -127,7 +130,9 @@ class SoundSender(AbcSender):
) )
} }
with SoundSender.super_global_multi_sender_preventer:
r = requests.post(urljoin(self._feed_url, config.FEED_TYPE), files=files) r = requests.post(urljoin(self._feed_url, config.FEED_TYPE), files=files)
logging.debug(f"Content: {r.content.decode()}") logging.debug(f"Content: {r.content.decode()}")
logging.debug(f"Headers: {r.headers}") logging.debug(f"Headers: {r.headers}")
r.raise_for_status() r.raise_for_status()