title: how to check/trace why a python script delays to exit
body: <p>I have a python script that does some network stuff with the requests library. My issue is that for some reason the python script doesn't seem to exit immediately after it finishes.</p>
  <p>I have measured the execution call of the function I use and of the total execution of the script with <code>time.perf_counter()</code>.</p>
  <pre><code>--ipTest completed in 134.34 sec
  
  --Program completed in 134.34 sec
  </code></pre>
  <p>But the script stops (writes on the file the output and exits) after 260 seconds. This is not always the case though, sometimes this is happening.</p>
  <p>Is there a way to check what the script is doing the rest of the time?</p>
  <p>Thanks!</p>