Connecting twice with twisted - how to do that correctly?

后端 未结 4 2005
一生所求
一生所求 2021-02-09 15:42

I want to use twisted (and StarPy which is a protocol implementation for asterisk ami) to connect to an asterisk server. The application initiates a outgoing fax there. I found

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-09 16:45

    If you're still looking for a solution... I had this same issue. I have a script that uses Twisted to execute a program on a remote server. I needed a way to run that script synchronously from within a django application. What I ended up doing was making my Twisted script call the remote server and just print to stdout. Then from within my Django app I executed that script via subprocess.Popen and set stdout=PIPE so I could capture the output from my Twisted script and use it in my Django app.

    This isn't really ideal, and pretty much defeats the purpose of Twisted, but this gets past the "not being able to call reactor.run() a second time, since the Twisted script runs in it's own process each time.

    This did end up working great for me, and it sounds very similar to the same situation that you're in. I hope this helps. Good luck. (I can post some code samples if you think it would help, just let me know).

提交回复
热议问题