Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crochet crashing when MainThread isn't available when _shutdown module is loaded #69

Closed
wants to merge 1 commit into from

Conversation

lieryan
Copy link

@lieryan lieryan commented Sep 10, 2014

This pull request fixes a situation where this bug causes projects using crotchet with autonose to not be able to rerun changed tests because crochet cannot find the MainThread.

$ cat demo.py
from crochet import setup, run_in_reactor, TimeoutError
$ cat test_demo.py
import unittest
class Test(unittest.TestCase):
    def test_foo(self):
        import demo
$ 0launch http://gfxmonk.net/dist/0install/autonose.xml &
$ # ... wait for autonose to load and finish testing ...
$ touch demo.py

Got:

======================================================================
ERROR: test_foo (test_demo.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/path/to/project/test_demo.py", line 4, in test_foo
    import demo
  File "/path/to/project/demo.py", line 1, in <module>
    from crochet import setup, run_in_reactor, TimeoutError
  File "/path/to/env/src/crochet/crochet/__init__.py", line 25, in <module>
    from ._shutdown import _watchdog, register
  File "/path/to/env/src/crochet/crochet/_shutdown.py", line 59, in <module>
    if t.name == "MainThread"][0], _registry.run)
IndexError: list index out of range

----------------------------------------------------------------------
Ran 1 test in 0.022s

FAILED (errors=1)

Expected:

  1. test reruns successfully

@itamarst
Copy link
Owner

Thanks for the patch/bug report. I'll try to get a fix in for next release.

@itamarst
Copy link
Owner

While this change does mask the problem, it doesn't seem like it solves the underlying problem. Nor is it clear to me what exactly the underlying problem is - did MainThread ever exist in this setup? Or has it already exited? Not clear. So while I do want to fix the issue it probably won't be via this PR.

@itamarst
Copy link
Owner

I opened a new issue for this, #79.

@itamarst itamarst closed this Feb 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants