title: Python asyncio: event loop does not seem to stop when stop method is called
body: <p>I've got a simple test where I run a Python asyncio event loop using the <code>run_forever</code> method, and then immediately stop it in another thread. However, the event loop does not seem to terminate. I have the following test case:</p>
  
  <pre><code>import asyncio
  from threading import Thread
  
  loop = asyncio.get_event_loop()
  thread = Thread(target=loop.run_forever)
  thread.start()
  print('Started!')
  loop.stop()
  print('Requested stop!')
  thread.join()
  print('Finished!')
  </code></pre>
  
  <p>This test case prints:</p>
  
  <pre><code>Started!
  Requested stop!
  </code></pre>
  
  <p>So, the test seems to block on <code>thread.join()</code>, waiting for the event loop to terminate.</p>
  
  <p>If I dump my threads I get the following:</p>
  
  <pre><code>Thread 0x00007000087ec000 (most recent call first):
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/selectors.py", line 577 in select
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/base_events.py", line 1388 in _run_once
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/base_events.py", line 421 in run_forever
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 862 in run
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 914 in _bootstrap_inner
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 882 in _bootstrap
  
  Current thread 0x00007fffc6b273c0 (most recent call first):
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 1070 in _wait_for_tstate_lock
    File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/threading.py", line 1054 in join
  </code></pre>
  
  <p>I haven't looked to deeply at the Python code, but <code>selectors.py</code> seems to be waiting for work. I guess it's possible that this problem is occurring because I've called <code>stop</code> while there is no more work for the event loop to so, but this seems like it could be quite a problematic limitation.</p>
  
  <p>Or maybe I've misunderstood something about how this should work?</p>