Does dask distributed use Tornado coroutines for workers tasks?
<p>I've read at the dask <a href="http://distributed.readthedocs.io/en/latest/foundations.html#concurrency-with-tornado-coroutines" rel="nofollow"><code>distributed</code> documentation</a> that:</p>

<blockquote>
  <p>Worker and Scheduler nodes operate concurrently. They serve several
  overlapping requests and perform several overlapping computations at
  the same time without blocking.</p>
</blockquote>

<p>I've always thought single-thread concurrent programming is best suited for I/O expensive, not CPU-bound jobs. However I expect many dask tasks (e.g. <code>dask.pandas</code>, <code>dask.array</code>) to be CPU intensive.</p>

<p>Does distributed only use Tornado for client/server communication, with separate processes/threads to run the dask tasks? Actually <code>dask-worker</code> has <code>--nprocs</code> and <code>--nthreads</code> arguments so I expect this to be the case.</p>

<p>How do concurrency with Tornado coroutines and more common processes/threads processing each dask task live together in distributed?</p>

<p>You are correct.  </p>

<p>Each <a href="http://distributed.readthedocs.io/en/latest/worker.html" rel="nofollow">distributed.Worker</a> object contains a <a href="https://docs.python.org/3/library/concurrent.futures.html#threadpoolexecutor" rel="nofollow">concurrent.futures.ThreadPoolExecutor</a> with multiple threads.  Tasks are run on this <code>ThreadPoolExecutor</code> for parallel performance.  All communication and coordination tasks are managed by the Tornado IOLoop.</p>

<p>Generally this solution allows computation to happen separately from communication and administration.  This allows parallel computing within a worker and allows workers to respond to server requests even while computing tasks.</p>

<h3>Command line options</h3>

<p>When you make the following call:</p>

<pre><code>dask-worker --nprocs N --nthreads T
</code></pre>

<p>It starts <code>N</code> separate <code>distributed.Worker</code> objects in separate Python processes.  Each of these workers has a ThreadPoolExecutor with <code>T</code> threads.</p>

python multithreading tornado coroutine dask