Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes from @arconamagi #70

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion switchio/apps/dtmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion switchio/apps/players.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions switchio/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions switchio/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down