Starting sanic from existing app

I have a plugin to my software that currently runs a cherrypy server. The plugin must run in my existing python context to access some data. The issue is that when I call app.run(), it stops there (doesn’t continue processing). I tried starting it in a thread but got the error ValueError('add_signal_handler() can only be called from the main thread'), <traceback object at 0x106031b40>).

So, I need to start sanic up in a way that doesn’t stop processing in the main thread. Cherrypy didn’t have any issue starting up like this and I’m really hoping that there is some way to get sanic running like this as well. Thoughts?

Please share some reference code - this isn’t enough to go on.

When you try to start sanic in a new Thread (not the main thread), it fails with the above error. You can, however, pass register_sys_signals=False to the run() method and it won’t attempt to install those signals and therefore will start up successfully.