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

possible bug (race condition) in injector's __import__ handling #40

Closed
yarikoptic opened this issue Aug 7, 2015 · 4 comments
Closed

Comments

@yarikoptic
Copy link
Member

see e.g. https://travis-ci.org/duecredit/duecredit/jobs/74501423#L261 failure. Was "resolved" by next identical in functionality push

  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/nose/result.py", line 182, in _exc_info_to_string
    from nose.plugins.skip import SkipTest
  File "/home/travis/build/duecredit/duecredit/duecredit/injections/injector.py", line 228, in __import
    return self._orig_import(name, *args, **kwargs)

TypeError: 'NoneType' object is not callable
@yarikoptic
Copy link
Member Author

another manifestation reported by @mvdoc:
https://travis-ci.org/duecredit/duecredit/jobs/75193538

======================================================================
ERROR: duecredit.tests.test_injections.test_no_double_activation
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/travis/build/duecredit/duecredit/duecredit/tests/test_injections.py", line 142, in test_no_double_activation
    injector.activate()
  File "/home/travis/build/duecredit/duecredit/duecredit/injections/injector.py", line 219, in activate
    raise RuntimeError("__import__ is already duecredited")
RuntimeError: __import__ is already duecredited
-------------------- >> begin captured logging << --------------------
duecredit: WARNING: _orig_import is not yet known, so we haven't decorated default importer yet. Nothing TODO
--------------------- >> end captured logging << ---------------------

@yarikoptic
Copy link
Member Author

I think it is Python bug somewhere... not sure where or how, but I do not see how

    print("Assigned4: %s" % DueCreditInjector._orig_import)
    globs = glob(ptrn)
    print("Assigned5: %s" % DueCreditInjector._orig_import)

could result in

Assigned4: <built-in function __import__>
Assigned5: None

@yarikoptic
Copy link
Member Author

btw, "bug" goes away also if there is more output, e.g. running nosetests with -v or dumping output at higher DUECREDIT_LOGLEVEL.

@yarikoptic
Copy link
Member Author

it is so much more fun! e.g. if I remove .pyc files -- we work fine, but then would fail on the next run:

2 11919.....................................:Wed 12 Aug 2015 06:48:30 PM EDT:.
(git)hopa:~/proj/duecredit[pr-41]git
$> find -iname *pyc -delete
2 11920.....................................:Wed 12 Aug 2015 06:48:46 PM EDT:.
(git)hopa:~/proj/duecredit[pr-41]git
$> .tox/py27/bin/nosetests -s duecredit
.......2015-08-12 18:48:49,620 [ERROR  ] Just use nosetests duecredit for now (NotImplementedError) (main.py:178)
.....................SS.......2015-08-12 18:48:49,633 [WARNING] Seems that we are calling duecredit_importer twice. No harm is done but shouldn't happen (injector.py:280)
...2015-08-12 18:48:49,635 [WARNING] _orig_import is not yet known, so we haven't decorated default importer yet. Nothing TODO (injector.py:330)
.........SSSSSSSS
----------------------------------------------------------------------
Ran 57 tests in 0.088s

OK (SKIP=10)
2 11921.....................................:Wed 12 Aug 2015 06:48:49 PM EDT:.
(git)hopa:~/proj/duecredit[pr-41]git
$> .tox/py27/bin/nosetests -s duecredit
.......2015-08-12 18:48:51,144 [ERROR  ] Just use nosetests duecredit for now (NotImplementedError) (main.py:178)
.....................SS..2015-08-12 18:48:51,156 [ERROR  ] For some reason self._orig_import is None. Importing using stock importer to mitigate (injector.py:253)
2015-08-12 18:48:51,156 [ERROR  ] For some reason self._orig_import is None. Importing using stock importer to mitigate (injector.py:253)
Traceback (most recent call last):
  File ".tox/py27/bin/nosetests", line 11, in <module>
    sys.exit(run_exit())
  File "/home/yoh/proj/duecredit/.tox/py27/local/lib/python2.7/site-packages/nose/core.py", line 121, in __init__
    **extra_args)
  File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
    self.runTests()
  File "/home/yoh/proj/duecredit/.tox/py27/local/lib/python2.7/site-packages/nose/core.py", line 207, in runTests
    result = self.testRunner.run(self.test)
  File "/home/yoh/proj/duecredit/.tox/py27/local/lib/python2.7/site-packages/nose/core.py", line 62, in run
    test(result)
  File "/home/yoh/proj/duecredit/.tox/py27/local/lib/python2.7/site-packages/nose/suite.py", line 177, in __call__

mvdoc added a commit that referenced this issue Aug 12, 2015
ENH+DOC: always check if _orig_import is not None (Closes #40)
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

No branches or pull requests

1 participant