Twisted threading and Thread Pool Difference
<p>What is the difference between using</p>

<pre><code>from twisted.internet import reactor, threads
</code></pre>

<p>and just using</p>

<pre><code>import thread 
</code></pre>

<p>using a thread pool?</p>

<p>What is the twisted thing actually doing? Also, is it safe to use twisted threads?</p>

<blockquote>
  <p>What is the difference</p>
</blockquote>

<p>With <code>twisted.internet.threads</code>, Twisted will manage the thread and a thread pool for you. This puts less of a burden on devs and allows devs to focus more on the business logic instead of dealing with the idiosyncrasies of threaded code. If you <code>import thread</code> yourself, then you have to manage threads, get the results from threads, ensure results are synchronized, make sure too many threads don't start up at once, fire a callback once the threads are complete, etc.</p>

<blockquote>
  <p>What is the twisted thing actually doing?</p>
</blockquote>

<p>It depends on what "thing" you're talking about. Can you be more specific? Twisted has various thread functions you can leverage and each may function slightly different from each other.</p>

<blockquote>
  <p>And is it safe to use twisted threads.</p>
</blockquote>

<p>It's absolutely safe! I'd say it's more safe than managing threads yourself. Take a look at all the functionality that Twisted's thread provides, then think about if you had to write this code yourself. If you've ever worked with threads, you'll know what it starts off simple enough, but as your application grows and if you didn't make good decisions about threads, then your application can become very complicated and messy. In general, Twisted will handle the threads in a uniform way and in a way that devs would expect a well behaved threaded app to behave.</p>

<h1>References</h1>

<ul>
<li><a href="https://twistedmatrix.com/documents/current/core/howto/threading.html" rel="nofollow">https://twistedmatrix.com/documents/current/core/howto/threading.html</a></li>
</ul>

python multithreading security threadpool twisted