Prevented muliprocessing
This commit is contained in:
parent
0ea6b8c69b
commit
4e7f3b79a6
@ -9,6 +9,8 @@ import os
|
|||||||
|
|
||||||
from utils import BirbnetesIoTPlatformStatusDriver
|
from utils import BirbnetesIoTPlatformStatusDriver
|
||||||
|
|
||||||
|
from threading import Lock
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Abstract base class for signalprocessor
|
Abstract base class for signalprocessor
|
||||||
"""
|
"""
|
||||||
@ -24,6 +26,8 @@ class SoundSignalProcessor(AbcSignalProcessor):
|
|||||||
SoundSignalProcessor class, responsible for handling the sound signal processor pipeline.
|
SoundSignalProcessor class, responsible for handling the sound signal processor pipeline.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
super_multi_signal_processing_preventor_to_make_queue_great_again = Lock()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""
|
"""
|
||||||
Create dependency objects.
|
Create dependency objects.
|
||||||
@ -37,28 +41,29 @@ class SoundSignalProcessor(AbcSignalProcessor):
|
|||||||
Process a sound sample.
|
Process a sound sample.
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
soundsample_name = self.soundsensor.getvalue()
|
with SoundSignalProcessor.super_multi_signal_processing_preventor_to_make_queue_great_again:
|
||||||
|
soundsample_name = self.soundsensor.getvalue()
|
||||||
|
|
||||||
if not soundsample_name: # No new sample... nothing to do
|
if not soundsample_name: # No new sample... nothing to do
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sample_decision = self.soundpreprocessor.preprocesssignal(soundsample_name)
|
sample_decision = self.soundpreprocessor.preprocesssignal(soundsample_name)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
BirbnetesIoTPlatformStatusDriver.enqueue_pattern('red', [1, 1, 1])
|
BirbnetesIoTPlatformStatusDriver.enqueue_pattern('red', [1, 1, 1])
|
||||||
os.unlink(soundsample_name)
|
os.unlink(soundsample_name)
|
||||||
return
|
return
|
||||||
|
|
||||||
if sample_decision:
|
if sample_decision:
|
||||||
BirbnetesIoTPlatformStatusDriver.enqueue_pattern('green', [1, 0, 1])
|
BirbnetesIoTPlatformStatusDriver.enqueue_pattern('green', [1, 0, 1])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.soundsender.sendvalue(soundsample_name, sample_decision)
|
self.soundsender.sendvalue(soundsample_name, sample_decision)
|
||||||
except (ConnectionError, requests.HTTPError) as e:
|
except (ConnectionError, requests.HTTPError) as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
BirbnetesIoTPlatformStatusDriver.enqueue_pattern('red', [1, 0, 1, 0, 1])
|
BirbnetesIoTPlatformStatusDriver.enqueue_pattern('red', [1, 0, 1, 0, 1])
|
||||||
os.unlink(soundsample_name)
|
os.unlink(soundsample_name)
|
||||||
return
|
return
|
||||||
|
|
||||||
os.unlink(soundsample_name)
|
os.unlink(soundsample_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user