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

Handle exceptions in load_extensions #1337

Closed

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Nov 28, 2015

This will skip those extensions, instead of crashing mopidy, e.g. when
mopidy-mopify fails because of a missing HOME environment variable
during mopidy's tests.
Ref: dirkgroenen/mopidy-mopify#119

Please note that the error will not show up with --help, because the logging is not setup then yet.

This will skip those extensions, instead of crashing mopidy, e.g. when
mopidy-mopify fails because of a missing HOME environment variable
during mopidy's tests.
Ref: dirkgroenen/mopidy-mopify#119
@blueyed
Copy link
Contributor Author

blueyed commented Nov 28, 2015

Some more information of the crash during test_help_has_mopidy_options:

({u'PYTHONPATH': u'…/mopidy/mopidy/..:'}, ['…/mopidy/.tox/py27/bin/python2.7', '…/mopidy/mopidy', u'--help'])

Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "…/mopidy/mopidy/__main__.py", line 239, in <module>
    sys.exit(main())
  File "…/mopidy/mopidy/__main__.py", line 69, in main
    extensions_data = ext.load_extensions()
  File "…/mopidy/mopidy/ext.py", line 201, in load_extensions
    extension_class = entry_point.load(require=False)
  File "…/mopidy/.tox/py27/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2355, in load
    return self.resolve()
  File "…/mopidy/.tox/py27/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2361, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/site-packages/mopidy_mopify/__init__.py", line 9, in <module>
    from services.sync import sync
  File "/usr/lib/python2.7/site-packages/mopidy_mopify/services/sync/sync.py", line 9, in <module>
    class Sync(object):
  File "/usr/lib/python2.7/site-packages/mopidy_mopify/services/sync/sync.py", line 16, in Sync
    syncfile = os.path.join(userhome, directory, filename)
  File "…/mopidy/.tox/py27/lib/python2.7/posixpath.py", line 70, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'

except Exception as e:
logger.exception("Failed to load extension {}: {}".format(
entry_point.name, e
), exc_info=e)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logger.exception() will get the exc_info itself without explicitly passing it since this is inside an except block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, will change it.

@jodal
Copy link
Member

jodal commented Nov 28, 2015

I'm positive to just logging the stack trace and continuing if an extension crashes during setup. All the debug information we used to have will still be available, and Mopidy remains usable, probably causing less bugs reported on Mopidy core.

@jodal jodal self-assigned this Nov 28, 2015
@jodal jodal added this to the v1.2 - Gapless milestone Nov 28, 2015
@blueyed
Copy link
Contributor Author

blueyed commented Nov 28, 2015

Pushed a fixup-commit.
That should be squashed before/when merging.
Let me know if/when I should do it.

@jodal
Copy link
Member

jodal commented Nov 28, 2015

Squashed and merged in b3ec02d.

Thanks! :-)

@jodal jodal closed this Nov 28, 2015
@blueyed blueyed deleted the handle-exception-in-extensions branch November 28, 2015 22:59
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