mitodl/micromasters

Error initializing sentry on django ipython shell

Opened this issue · 0 comments

I'm not sure if this happens locally, but on heroku, if you run ./manage.py shell, this error is logged, it's possibly related to #5306 as that's the RC where it was first noticed, but I'm not certain.

~ $ ./manage.py shell
[2023-04-19 16:07:40] DEBUG 10 [asyncio] selector_events.py:59 - [d4c87a19-5c8f-44c9-b346-50b6c1b10f20] - Using selector: EpollSelector
--- Logging error ---
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.9/logging/handlers.py", line 959, in emit
    self.socket.sendto(msg, self.address)
OSError: [Errno 9] Bad file descriptor
Call stack:
  File "/app/./manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/commands/shell.py", line 99, in handle
    return getattr(self, shell)(options)
  File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/commands/shell.py", line 36, in ipython
    start_ipython(argv=[])
  File "/app/.heroku/python/lib/python3.9/site-packages/IPython/__init__.py", line 124, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/app/.heroku/python/lib/python3.9/site-packages/traitlets/config/application.py", line 1042, in launch_instance
    app.initialize(argv)
  File "/app/.heroku/python/lib/python3.9/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/app/.heroku/python/lib/python3.9/site-packages/IPython/terminal/ipapp.py", line 279, in initialize
    self.init_shell()
  File "/app/.heroku/python/lib/python3.9/site-packages/IPython/terminal/ipapp.py", line 293, in init_shell
    self.shell = self.interactive_shell_class.instance(parent=self,
  File "/app/.heroku/python/lib/python3.9/site-packages/traitlets/config/configurable.py", line 551, in instance
    inst = cls(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.9/site-packages/IPython/terminal/interactiveshell.py", line 688, in __init__
    self.init_prompt_toolkit_cli()
  File "/app/.heroku/python/lib/python3.9/site-packages/IPython/terminal/interactiveshell.py", line 466, in init_prompt_toolkit_cli
    self.pt_loop = asyncio.new_event_loop()
  File "/app/.heroku/python/lib/python3.9/asyncio/events.py", line 761, in new_event_loop
    return get_event_loop_policy().new_event_loop()
  File "/app/.heroku/python/lib/python3.9/asyncio/events.py", line 659, in new_event_loop
    return self._loop_factory()
  File "/app/.heroku/python/lib/python3.9/asyncio/unix_events.py", line 54, in __init__
    super().__init__(selector)
  File "/app/.heroku/python/lib/python3.9/asyncio/selector_events.py", line 59, in __init__
    logger.debug('Using selector: %s', selector.__class__.__name__)
  File "/app/.heroku/python/lib/python3.9/logging/__init__.py", line 1422, in debug
    self._log(DEBUG, msg, args, **kwargs)
  File "/app/.heroku/python/lib/python3.9/logging/__init__.py", line 1577, in _log
    self.handle(record)
  File "/app/.heroku/python/lib/python3.9/logging/__init__.py", line 1587, in handle
    self.callHandlers(record)
  File "/app/.heroku/python/lib/python3.9/site-packages/sentry_sdk/integrations/logging.py", line 86, in sentry_patched_callhandlers
    return old_callhandlers(self, record)
Message: 'Using selector: %s'
Arguments: ('EpollSelector',)
Python 3.9.1 (default, Dec  8 2020, 10:26:12)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.10.0 -- An enhanced Interactive Python. Type '?' for help.

[2023-04-19 16:07:41] DEBUG 10 [asyncio] selector_events.py:59 - [d4c87a19-5c8f-44c9-b346-50b6c1b10f20] - Using selector: EpollSelector
--- Logging error ---
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.9/logging/handlers.py", line 959, in emit
    self.socket.sendto(msg, self.address)
OSError: [Errno 9] Bad file descriptor
Call stack:
  File "/app/./manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/commands/shell.py", line 99, in handle
    return getattr(self, shell)(options)
  File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/commands/shell.py", line 36, in ipython
    start_ipython(argv=[])
  File "/app/.heroku/python/lib/python3.9/site-packages/IPython/__init__.py", line 124, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/app/.heroku/python/lib/python3.9/site-packages/traitlets/config/application.py", line 1043, in launch_instance
    app.start()
  File "/app/.heroku/python/lib/python3.9/site-packages/IPython/terminal/ipapp.py", line 318, in start
    self.shell.mainloop()
  File "/app/.heroku/python/lib/python3.9/site-packages/IPython/terminal/interactiveshell.py", line 720, in mainloop
    self.interact()
  File "/app/.heroku/python/lib/python3.9/site-packages/IPython/terminal/interactiveshell.py", line 705, in interact
    code = self.prompt_for_code()
  File "/app/.heroku/python/lib/python3.9/site-packages/IPython/terminal/interactiveshell.py", line 634, in prompt_for_code
    old_loop = get_asyncio_loop()
  File "/app/.heroku/python/lib/python3.9/site-packages/IPython/core/async_helpers.py", line 47, in get_asyncio_loop
    _asyncio_event_loop = asyncio.new_event_loop()
  File "/app/.heroku/python/lib/python3.9/asyncio/events.py", line 761, in new_event_loop
    return get_event_loop_policy().new_event_loop()
  File "/app/.heroku/python/lib/python3.9/asyncio/events.py", line 659, in new_event_loop
    return self._loop_factory()
  File "/app/.heroku/python/lib/python3.9/asyncio/unix_events.py", line 54, in __init__
    super().__init__(selector)
  File "/app/.heroku/python/lib/python3.9/asyncio/selector_events.py", line 59, in __init__
    logger.debug('Using selector: %s', selector.__class__.__name__)
  File "/app/.heroku/python/lib/python3.9/logging/__init__.py", line 1422, in debug
    self._log(DEBUG, msg, args, **kwargs)
  File "/app/.heroku/python/lib/python3.9/logging/__init__.py", line 1577, in _log
    self.handle(record)
  File "/app/.heroku/python/lib/python3.9/logging/__init__.py", line 1587, in handle
    self.callHandlers(record)
  File "/app/.heroku/python/lib/python3.9/site-packages/sentry_sdk/integrations/logging.py", line 86, in sentry_patched_callhandlers
    return old_callhandlers(self, record)
Message: 'Using selector: %s'
Arguments: ('EpollSelector',)