Replace blocking function calls with awaits.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Thu, 9 Jul 2020 20:18:06 +0000 (22:18 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Thu, 9 Jul 2020 20:18:06 +0000 (22:18 +0200)
lagarde.py

index 487b88c43816a15a3744d4d218780c4ac64f7149..75a81a780f1af6fba0eac5c0761a0f9b08258ab8 100755 (executable)
@@ -118,13 +118,13 @@ class Lagarde:
                     rd = GstWebRTC.WebRTCSessionDescription.new(GstWebRTC.WebRTCSDPType.OFFER, sm)
                     gst_promise = Gst.Promise.new()
                     self.webrtcbin.emit('set-remote-description', rd, gst_promise)
                     rd = GstWebRTC.WebRTCSessionDescription.new(GstWebRTC.WebRTCSDPType.OFFER, sm)
                     gst_promise = Gst.Promise.new()
                     self.webrtcbin.emit('set-remote-description', rd, gst_promise)
-                    gst_promise.wait()
+                    await asyncio.get_event_loop().run_in_executor(None, gst_promise.wait)
                     self.sdp_offer = None
 
                     log.info('create-answer')
                     gst_promise = Gst.Promise.new()
                     self.webrtcbin.emit('create-answer', None, gst_promise)
                     self.sdp_offer = None
 
                     log.info('create-answer')
                     gst_promise = Gst.Promise.new()
                     self.webrtcbin.emit('create-answer', None, gst_promise)
-                    result = gst_promise.wait()
+                    result = await asyncio.get_event_loop().run_in_executor(None, gst_promise.wait)
                     assert result == Gst.PromiseResult.REPLIED
                     reply = gst_promise.get_reply()
                     answer = reply.get_value('answer')
                     assert result == Gst.PromiseResult.REPLIED
                     reply = gst_promise.get_reply()
                     answer = reply.get_value('answer')
@@ -145,7 +145,7 @@ class Lagarde:
                     })
                     gst_promise = Gst.Promise.new()
                     self.webrtcbin.emit('set-local-description', answer, gst_promise)
                     })
                     gst_promise = Gst.Promise.new()
                     self.webrtcbin.emit('set-local-description', answer, gst_promise)
-                    gst_promise.wait()
+                    await asyncio.get_event_loop().run_in_executor(None, gst_promise.wait)
                     gst_promise.get_reply()
                     await self.websocket.send(sdp_answer_msg)
 
                     gst_promise.get_reply()
                     await self.websocket.send(sdp_answer_msg)