Comments (1)
Hi @dronord, frankly asyncio is just another method to provide non-blocking behavior to threading, which historically is our method of choice. Both have their advantages and disadvantages, but the functional difference is quite slim except threading would take advantage of multiple CPUs once GIL is lifted one day.
Such conversion is possible as proven by @space88man here: https://github.com/space88man/b2bua, however we are bit of conservative plus there is 10x more code in our private repo and related projects that share code such as rtp_cluster. Which makes it a bit challenging. At the same time, if you want to integrate sippy with async code that might be doable by just spinning either of them into its own thread and then communicate via callFromThread() or shared Queue between async and sippy.
Starting sippy stack in a thread is as trivial as:
from sippy.Core.EventDispatcher import ED2
class SIPfoo(threading.Thread):
def run(self):
ED2.my_ident = get_ident()
rval = ED2.loop()
def terminate(self):
ED2.callFromThread(ED2.breakLoop)
self.join()
This is a bit of a toy example, but you can find more functional one here on setting various parameters and initializing transaction manager:
https://github.com/sippy/Infernos/blob/696c6ecca82f03e90952572886b12af21a71444a/SIP/InfernSIP.py#L64
Then you can create a special queue, which you can create from your async code and invoke various functions (such as transaction manager) in that stack using the following the following pattern:
rval = Queue()
ED2.callFromThread(self.sip_stack.new_session, msg, rval, on_create=rval.put)
sip_sess, rtp_sess = rval.get()
return (sip_sess.id, self.rtp_actr, rtp_sess.sess_id)
Most of the functions of interest provide some kind of callback that you can then use with a partial and/or wrapper class with call() method to filter results (of catch error) and pass it on the queue.
Queue is a built-in object so it should provide all asyncio semantics. So that you can then go and do your async stuff and will be awaken when needed.
from b2bua.
Related Issues (20)
- RTCP SDP attribute pass from ingress call leg to egress call leg unmodified
- TCP support
- b2bua_simple not changing Call_Id HOT 1
- Sippy b2bua rtpengine compatibility HOT 1
- on run of b2bua_simple : AttributeError: 'unicode' object has no attribute 'localStr' HOT 3
- Can't start with or without libelperiodic HOT 6
- [Question] SipTransactionManager handles UAC ACKs vs RFC6026 HOT 1
- clock_gettime cannot be found in libs HOT 1
- freeradius-client dictionary problem HOT 1
- MonoTime is not being used for credit-time, expires and np_expires HOT 9
- Get Radius attributes for authentication request from SIP Header HOT 3
- B2BUA Support for DNS SRV Record HOT 1
- Issue with Radius
- Use the remote address in From and To headers
- [Off-topic]Ghost of Twisted - sippy_async - monkey patch to support running on anyio
- Outbound Proxy - Not working
- Make b2bua reply to OPTIONS
- CallID preserved. Needs to be changed
- Please provide a 'Transparent Header' or 'Wildcard Header' support option
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from b2bua.