title: Pytest hangs when running with other threads
body: <p>I am trying to run pytest from within python after running a thread,
  here is a simple example of the case:</p>
  
  <pre><code>import time
  import threading
  import pytest
  
  
  class A(object):
      def __init__(self):
          self._thread_a = threading.Thread(target=self.do_a)
          self._thread_a.start()
          pytest.main()
  
      def do_a(self):
          print "a"
          time.sleep(2)
          self.do_a()
  
  
  if __name__ == "__main__":
      a = A()
  </code></pre>
  
  <p>but pytest keeps hanging. this is what the output looks like:</p>
  
  <pre><code>============================= test session starts ==============================
  platform darwin -- Python 2.7.10, pytest-3.3.2, py-1.5.2, pluggy-0.6.0
  metadata: {'Python': '2.7.10', 'Platform': 'Darwin-17.3.0-x86_64-i386-64bit', 'Packages': {'py': '1.5.2', 'pytest': '3.3.2', 'pluggy': '0.6.0'}, 'Plugins': {'session2file': '0.1.9', 'celery': '4.0.0','html': '1.16.1', 'metadata': '1.5.1'}}
  rootdir: /Users/path/to/root/dir, inifile:
  plugins: session2file-0.1.9, metadata-1.5.1, html-1.16.1, celery-4.0.0
  </code></pre>
  
  <p>and it just hangs like this until I force quit it.
  is there any way to make this work?</p>