schrodinger.infra.exception_handler module

A top level Python exception handler that prevents uncaught exceptions in Python scripts from crashing Maestro.

To activate the exception handler use exception_handler.set_exception_handler(). That will activate the appropriate exception handler.

If SCHRODINGER_DEV_DEBUG or SCHRODINGER_SRC are defined, we install a handler that simply prints tracebacks to the terminal. Otherwise (generally on customer machines), we install a handler that writes uncaught exceptions to a folder in .schrodinger. The user is informed of the error and told to contact customer service.

class schrodinger.infra.exception_handler.ExceptionRecorder

Bases: object

A top level exception handler that writes uncaught exceptions to a folder in .schrodinger. The user is informed of the error and told to contact customer service.

This handler can be activated by sys.excepthook = ExceptionRecorder() or by calling the enable_handler() convenience function.

Variables
  • _OPENFLAGS (int) – The flags used when opening a file. These flags are set to ensure that files are opened in a thread-safe manner.

  • _EXCEPTIONS_DIR (str) – The directory where exceptions are stored

  • _MAX_EXCEP_FILES (int) – The maximum number of files allowed in the exceptions directory. Once this number of files is hit, the oldest files will be erased after recording the next exception.

__init__()
schrodinger.infra.exception_handler.get_exception_handler()

Returns the appropriate exception handler, depending on values in the user’s environment.

schrodinger.infra.exception_handler.log_and_print_exception(etype, value, tb)

Prints the exception to the terminal and logs it to telemetry.

schrodinger.infra.exception_handler.set_exception_handler(handler=None)

Sets the appropriate top-level Python exception handler. We use one for customers and another for developers.

There is no effect if there is already a custom exception handler.