From 66e45b7d7465b0ef890fd5dba8e0cd58c027e316 Mon Sep 17 00:00:00 2001 From: "D.Labuzov" Date: Fri, 9 Mar 2018 05:37:06 +0300 Subject: [PATCH 1/3] using a valid silence stream value --- switchio/apps/dtmf.py | 2 +- switchio/apps/players.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 From 86153ba30160fef2d511d2e858b63014fc084456 Mon Sep 17 00:00:00 2001 From: "D.Labuzov" Date: Fri, 9 Mar 2018 05:40:05 +0300 Subject: [PATCH 2/3] trimming spaces from event Body --- switchio/connection.py | 2 ++ 1 file changed, 2 insertions(+) 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 From 1ebfd4d5837c72c4823dc0fd1f5cb701189807ac Mon Sep 17 00:00:00 2001 From: "D.Labuzov" Date: Fri, 9 Mar 2018 05:41:14 +0300 Subject: [PATCH 3/3] fix for a crash when -ERR USER_NOT_REGISTERED --- switchio/handlers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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