Thanks for the quick reply. I don't need Ampoule, since the tasks are simply calling some libreoffice api to convert documents to pdf format, but thank you all the same!<br><br><div class="gmail_quote">On Sat, Sep 1, 2012 at 1:53 PM, Glyph <span dir="ltr"><<a href="mailto:glyph@twistedmatrix.com" target="_blank">glyph@twistedmatrix.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
On Aug 31, 2012, at 10:30 PM, Shuai Lin <<a href="mailto:linshuai2012@gmail.com">linshuai2012@gmail.com</a>> wrote:<br>
<br>
> Hi all,<br>
><br>
> My server mainly consists of two modules:<br>
> -- http api handling (using twisted)<br>
> -- backend blocking tasks<br>
><br>
> The backend tasks have to block, because I have to call some third-party API, which is always blocking. What's more, since the third-party api call is blocking, I plan to use a thread pool to implement a connection pool.<br>
><br>
> My question is: Is it ok to use twisted in this manner? i.e. I just run `reactor.run()' in the main thread (to handle the http api request), and the rest of the program is blocking -- and intrinsically not related to twisted.<br>
><br>
> Any suggestion is appreciated. Thanks!<br>
<br>
</div></div>Sure, this is fine. This is why the reactor has callInThread() after all :). It may also make sense to use something like Ampoule <<a href="https://launchpad.net/ampoule" target="_blank">https://launchpad.net/ampoule</a>> if the backend tasks are CPU intensive as well, and you want multi-core parallelism.<br>
<span class="HOEnZb"><font color="#888888"><br>
-glyph<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</font></span></blockquote></div><br>