title: in a single thread application server(flask) that handling a time consuming request(CPU-bound), what will happen to other requests?
body: <p><strong>in short</strong>:
  I expect that while a single-threaded server is handling a request other requests must be dropped, (so the browser must continuously send that HTTP request to finally get the response) but in my example, this is not happening. why?</p>
  <hr />
  <p>in my simple flask app I have two routes that, corresponding view function returns as follow:</p>
  <ol>
  <li><code>/fibo</code> that returns a JSON that contains the start and end of execution of view function that calculates Fibonacci 37. I use the recursive version of Fibonacci as a CPU-bound process.
  <code>start_process</code> and <code>end_process</code> value is in the form of <code>%M:%S</code> (the current time's minute and second will be displayed).</li>
  <li><code>/fibo2</code> that contains the same logic as <code>/fibo</code>. (i will use it to better illuster my question)</li>
  </ol>
  <pre><code>an example of returned JSON response is like this:
  {&quot;start_process&quot;:&quot;02:02&quot;,
  &quot;fibo execution time&quot;:&quot;7.22&quot;,&quot;fibo(37)&quot;:24157817,
  &quot;end_process&quot;:&quot;02:09&quot;}
  </code></pre>
  <p>I run the app by <code>flask run</code> command. I send two <code>get</code> requests to <code>/fibo</code> route, in separate tabs with the browser (while the first tab is loading I sent the second request)
  the responses for each one are:</p>
  <pre><code>{&quot;start_process&quot;:&quot;02:02&quot;,
  &quot;fibo execution time&quot;:&quot;7.22&quot;,
  &quot;fibo(37)&quot;:24157817,
  &quot;end_process&quot;:&quot;02:09&quot;}
  </code></pre>
  <p>and</p>
  <pre><code>{&quot;start_process&quot;:&quot;02:09&quot;,
  &quot;fibo execution time&quot;:&quot;6.93&quot;,
  &quot;fibo(37)&quot;:24157817,
  &quot;end_process&quot;:&quot;02:16&quot;}
  </code></pre>
  <p>as the JSON responses illuster the second process started after that the first request is finished its job.</p>
  <p>the Wireshark log of this process is :
  <a href="https://i.stack.imgur.com/nh1BO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nh1BO.png" alt="enter image description here" /></a>
  in this section, my question is why after that for each of the separate requests TCP handshake happened the second request's <code>get</code> was sent after receiving the response of the first request? <strong>I expect that I must see lost HTTP packets, in Wireshark</strong></p>
  <hr />
  <p>I repeat this step and send requests to each of routes <code>/fibo</code> and <code>/fibo2</code> the results are:</p>
  <pre><code>{&quot;start_process&quot;:&quot;29:41&quot;,
  &quot;fibo execution time&quot;:&quot;16.30&quot;,
  &quot;fibo(37)&quot;:24157817,
  &quot;end_process&quot;:&quot;29:58&quot;
  }
  </code></pre>
  <p>and</p>
  <pre><code>{&quot;start_process&quot;:&quot;29:43&quot;,
  &quot;fibo execution time&quot;:&quot;16.21&quot;,
  &quot;fibo(37)&quot;:24157817,
  &quot;end_process&quot;:&quot;29:59&quot;
  }
  </code></pre>
  <p>this time the requests are started approximately at the same time. ( maybe the 2-second delay is because of the time spent entering the second request in the browser.) but this time the time of executing the Fibonacci is doubled.</p>
  <p>this time as the Wireshark shows the HTTP requests are sent separately from each other.
  <a href="https://i.stack.imgur.com/sOye5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sOye5.png" alt="enter image description here" /></a></p>
  <hr />
  <p>codes for flask app:</p>
  <pre><code>import re
  from flask import Flask, request
  from fibo import fib_t
  from datetime import datetime
  
  app = Flask(__name__)
  
  @app.route('/home')
  def hello():
      return 'hello '
  
  @app.route('/fibo')
  def cal_fibo():
      start_p = datetime.now().strftime(&quot;%M:%S&quot;)
      v, duretion = fib_t(37)
      end_p = datetime.now().strftime(&quot;%M:%S&quot;)
  
      d = {'start_process':start_p,'fibo(37)':v,'fibo execution time':duretion, 'end_process':end_p}
      return d
  
  @app.route('/fibo2')
  def cal_fibo2():
      start_p = datetime.now().strftime(&quot;%M:%S&quot;)
      v, duretion = fib_t(37)
      end_p = datetime.now().strftime(&quot;%M:%S&quot;)
  
      d = {'start_process':start_p,'fibo(37)':v,'fibo execution time':duretion, 'end_process':end_p}
      return d
  
  
  if __name__ == '__main__':
      app.run(debug=True)
  </code></pre>
  <p>fibo module:</p>
  <pre><code>
  def fib(a):
      if a == 1 or a==2:
          return 1
      else:
          return fib(a-1) + fib(a-2)
  
  
  def fib_t(a):
      t = time.time()
      v = fib(a)
      return v, f'{time.time()-t:.2f}'
  
  
  if __name__ == '__main__':
      print(fib_t(38))
  </code></pre>