#4460 closed defect (fixed)
Python script on startup command-line, QTimer errors
| Reported by: | Tom Goddard | Owned by: | Eric Pettersen |
|---|---|---|---|
| Priority: | moderate | Milestone: | |
| Component: | Logging | Version: | |
| Keywords: | Cc: | ||
| Blocked By: | Blocking: | ||
| Notify when closed: | Platform: | all | |
| Project: | ChimeraX |
Description
If I start ChimeraX from a shell with a Python script argument and the Python script raises an error I get a hard to follow traceback where the actual error is listed followed by about 6 QTimer errors and ChimeraX fails to start.
Should give just the error that actually occurred in the script, and also ChimeraX should probably remain running.
Here's my example Python test.py script. ChimeraX apparently does not keep the file variable in the script global namespace so it raises an error.
print ('starting test.py with file = ', file)
$ "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/MacOS/ChimeraX" test.py
"/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/MacOS/ChimeraX" test.py
Traceback (most recent call last):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ChimeraX_main.py", line 813, in init
commands.run(sess, 'open %s' % StringArg.unparse(arg))
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/commands/run.py", line 36, in run
results = command.run(text, log=log, return_json=return_json)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/commands/cli.py", line 2852, in run
result = ci.function(session, kw_args)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/open_command/cmd.py", line 118, in cmd_open
models = Command(session, registry=registry).run(provider_cmd_text, log=log)[0]
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/commands/cli.py", line 2852, in run
result = ci.function(session, kw_args)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/open_command/cmd.py", line 179, in provider_open
models, status = collated_open(session, None, [data], data_format, _add_models,
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/open_command/cmd.py", line 404, in collated_open
return func(*func_args, func_kw)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core_formats/init.py", line 48, in open
return open_python_script(session, data, file_name)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/scripting.py", line 82, in open_python_script
_exec_python(session, code, argv)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/scripting.py", line 59, in _exec_python
exec(code, sandbox.dict)
File "test.py", line 1, in <module>
print ('starting test.py with file = ', file)
NameError: name 'file' is not defined
Error in sys.excepthook:
Traceback (most recent call last):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 297, in ehook
self.session.ui.thread_safe(self.report_exception, exc_info=exc_info)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/ui/gui.py", line 363, in thread_safe
func(*args, kw)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 443, in report_exception
self.info(tb_msg, is_html=True)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 388, in info
self._log(Log.LEVEL_INFO, msg, add_newline, image, is_html,
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 498, in _log
if log.log(*args):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 340, in log
self.show_page_source()
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 344, in show_page_source
self.session.ui.thread_safe(self._show)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/ui/gui.py", line 363, in thread_safe
func(*args, kw)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 348, in _show
self.regulating_timer.start(100)
RuntimeError: wrapped C/C++ object of type QTimer has been deleted
Original exception was:
Traceback (most recent call last):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/ui/gui.py", line 202, in cx_qt_msg_handler
self.session.logger.method_map[log_level](msg_string)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 465, in warning
self._log(Log.LEVEL_WARNING, msg, add_newline, image, is_html,
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 498, in _log
if log.log(*args):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 340, in log
self.show_page_source()
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 344, in show_page_source
self.session.ui.thread_safe(self._show)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/ui/gui.py", line 363, in thread_safe
func(*args, kw)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 348, in _show
self.regulating_timer.start(100)
RuntimeError: wrapped C/C++ object of type QTimer has been deleted
Error in sys.excepthook:
Traceback (most recent call last):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 297, in ehook
self.session.ui.thread_safe(self.report_exception, exc_info=exc_info)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/ui/gui.py", line 363, in thread_safe
func(*args, kw)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 443, in report_exception
self.info(tb_msg, is_html=True)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 388, in info
self._log(Log.LEVEL_INFO, msg, add_newline, image, is_html,
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 498, in _log
if log.log(*args):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 340, in log
self.show_page_source()
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 344, in show_page_source
self.session.ui.thread_safe(self._show)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/ui/gui.py", line 363, in thread_safe
func(*args, kw)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 348, in _show
self.regulating_timer.start(100)
RuntimeError: wrapped C/C++ object of type QTimer has been deleted
Original exception was:
Traceback (most recent call last):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/ui/gui.py", line 202, in cx_qt_msg_handler
self.session.logger.method_map[log_level](msg_string)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 465, in warning
self._log(Log.LEVEL_WARNING, msg, add_newline, image, is_html,
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 498, in _log
if log.log(*args):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 340, in log
self.show_page_source()
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 344, in show_page_source
self.session.ui.thread_safe(self._show)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/ui/gui.py", line 363, in thread_safe
func(*args, kw)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 348, in _show
self.regulating_timer.start(100)
RuntimeError: wrapped C/C++ object of type QTimer has been deleted
Error in sys.excepthook:
Traceback (most recent call last):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 297, in ehook
self.session.ui.thread_safe(self.report_exception, exc_info=exc_info)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/ui/gui.py", line 363, in thread_safe
func(*args, kw)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 443, in report_exception
self.info(tb_msg, is_html=True)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 388, in info
self._log(Log.LEVEL_INFO, msg, add_newline, image, is_html,
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 498, in _log
if log.log(*args):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 340, in log
self.show_page_source()
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 344, in show_page_source
self.session.ui.thread_safe(self._show)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/ui/gui.py", line 363, in thread_safe
func(*args, kw)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 348, in _show
self.regulating_timer.start(100)
RuntimeError: wrapped C/C++ object of type QTimer has been deleted
Original exception was:
Traceback (most recent call last):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/ui/gui.py", line 202, in cx_qt_msg_handler
self.session.logger.method_map[log_level](msg_string)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 465, in warning
self._log(Log.LEVEL_WARNING, msg, add_newline, image, is_html,
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/core/logger.py", line 498, in _log
if log.log(*args):
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 340, in log
self.show_page_source()
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 344, in show_page_source
self.session.ui.thread_safe(self._show)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/ui/gui.py", line 363, in thread_safe
func(*args, kw)
File "/Users/goddard/Desktop/ChimeraX April 1 2021.app/Contents/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chimerax/log/tool.py", line 348, in _show
self.regulating_timer.start(100)
RuntimeError: wrapped C/C++ object of type QTimer has been deleted
Change History (6)
comment:1 by , 5 years ago
| Component: | Input/Output → Logging |
|---|---|
| Owner: | changed from to |
comment:2 by , 5 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Now script errors only exit Chimera in nogui mode. It was the premature exit (before event loop runs) that was causing the problems because Qt was already deleted apparently when the QTimer was used.
comment:3 by , 5 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
The fix seems to have suppressed error reporting when opening files specified as arguments on the startup command-line in gui mode. For example,
ChimeraX.app/Contents/MacOS/ChimeraX test.py
produces no error when file test.py does not exist.
comment:4 by , 5 years ago
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
Added code to report these errors. Has the side effect of reporting "Unable to load numpy_formathandler accelerator from OpenGL_accelerate" to the log. Not 100% sure why.
follow-up: 5 comment:5 by , 5 years ago
Thanks. We milestone the numpy_formathandler warning for 1.2. I'll try to find that. Super annoying that PyOpenGL is so poorly maintained they simply left out a shared library apparently because their distribution were built when numpy was not installed.
comment:6 by , 5 years ago
Examining the stack, that message is emitted via the logging module as the status bar creates its OpenGL context, and shows up in the log since stdout/stderr are redirected there. Seems like that's how it should have always worked? Weird.
It seems that the Log panel is trying to display various messages after Qt has been shut down.
This happens just by putting a non-existent file on the startup command line, for example, "chimerax test.py". But it doesn't always happen. If I switch between trying it with different ChimeraX versions it seems to always happen with April 1 devel build and daily build.