You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
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.
Hello.
Are there any plans to use asyncio in this nice project?
The text was updated successfully, but these errors were encountered: