friends-of-freeswitch / switchio

asyncio powered FreeSWITCH cluster control
http://switchio.rtfd.io
Mozilla Public License 2.0
191 stars 28 forks source link

Allow easily running event processing "*not* in a background thread" #66

Open goodboy opened 5 years ago

goodboy commented 5 years ago

By default switchio's internal event loop spawns a background thread which runs an asyncio event loop for processing events from FS. The original reason for this was legacy (before porting to asyncio) but still serves a useful purpose - that you can run switchio non-blocking alongside other blocking frameworks or programs from a single python process.

Now that this project is officially python 3.5+ only and has full support for asyncio we should allow users to be able to run event processing all in thread (using one asyncio loop) if desired.

The changes required for this shouldn't be too hard, but we'll need to mess with some plumbing:

See @enp's example app using just the switchio.api.Connection in #61 for the original use case.