diff --git a/switchio/apps/dtmf.py b/switchio/apps/dtmf.py index d4f9270..7ee058f 100644 --- a/switchio/apps/dtmf.py +++ b/switchio/apps/dtmf.py @@ -38,7 +38,7 @@ def on_park(self, sess): "Transmitting DTMF seq '{}' for session '{}'" .format(self.sequence, sess.uuid) ) - sess.broadcast('playback::silence_stream://0') + sess.broadcast('playback::silence_stream://-1') sess.send_dtmf(''.join(map(str, self.sequence)), self.duration) @event_callback('DTMF') diff --git a/switchio/apps/players.py b/switchio/apps/players.py index 7ab4fba..8629f48 100644 --- a/switchio/apps/players.py +++ b/switchio/apps/players.py @@ -70,7 +70,7 @@ def prepost( self.rec_period = rec_period self.stereo = rec_stereo self.log = utils.get_logger(self.__class__.__name__) - self.silence = 'silence_stream://0' # infinite silence stream + self.silence = 'silence_stream://-1' # infinite silence stream self.iterations = iterations self.tail = 1.0 diff --git a/switchio/connection.py b/switchio/connection.py index 37dd6d8..c5fd97f 100644 --- a/switchio/connection.py +++ b/switchio/connection.py @@ -299,6 +299,8 @@ def _handle_socket_data(event): body = event.get('Body') if event else None if not body: return False, None + else: + body = body.strip() if '-ERR' in body.splitlines()[-1]: raise utils.APIError(body) return True, body diff --git a/switchio/handlers.py b/switchio/handlers.py index 10cdca8..aeb500e 100644 --- a/switchio/handlers.py +++ b/switchio/handlers.py @@ -170,8 +170,10 @@ def _handle_bj(self, e): resp = body.strip(ok + '\n') job = self.bg_jobs.get(job_uuid, None) + job_just_created = False if not job: job = Job(event=e) + job_just_created = True else: job.events.update(e) @@ -187,8 +189,9 @@ def _handle_bj(self, e): job.sess_uuid, str(body)) ) job.fail(resp) # fail the job - # always pop failed jobs - self.bg_jobs.pop(job_uuid) + if not job_just_created: + # always pop failed jobs + self.bg_jobs.pop(job_uuid) # append the id for later lookup and discard? self.failed_jobs[resp] += 1 consumed = True