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