overriding sys.excepthook

   4116   4   2
User Avatar
Member
30 posts
Joined:
Offline
Hi All,

Has anyone had any success with overriding Houdini's python sys.excepthook?

I'm using it for automated error reporting for our pipeline scripts.

houdini doesn't object if i pass sys.exepthook a custom function, but it never gets called.

cheers,
chrisg
User Avatar
Member
3 posts
Joined: 11月 2016
Offline
Hi there,

having the same issue here.

We would like to use Raven/Sentry for Error-Logging (https://github.com/getsentry/raven-python) [github.com]
which is build around sys.excepthook

basically:
def handle_exception(exc_type, exc_value, exc_traceback):
	print "there was a issue"
sys.excepthook = handle_exception
print 1 / 0

in any “normal” python-shell this just prints
"there was a issue".
in the houdini-python-shell I still get the usual Traceback
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
is this expected? Am I'm missing something here?


cheers
Loqy
Edited by Loqy0815 - 2016年11月22日 07:39:40
User Avatar
Member
30 posts
Joined:
Offline
Loqy,

the last comms i had with sidefx about this was:

I was told that Houdini's Python shell (in the GUI) uses Python's code.InteractiveInterpreter class which, for whatever reason, doesn't use sys.excepthook. The following code will change it to use sys.excepthook:

import sys
import houdiniInterpreter

def showtraceback(self):
sys.excepthook(*sys.exc_info())

houdiniInterpreter.HoudiniConsole.showtraceback = showtraceback

However, for other uncaught exceptions, like shelf tools, there's currently no way to customize the exception callback. There is an RFE submitted for this

in summary, you can override excepthook in the python shell window, but not shelf tools.

cheers,
chrisg
User Avatar
Member
3 posts
Joined: 11月 2016
Offline
Hi Chrisg,

sorry for the late reply.
My attention was draged into other things..

Thanks for the snipped and Information.
Will try that today.

cheers
Loqy
User Avatar
Member
201 posts
Joined: 7月 2015
Offline
Hey!

I know this has been many years ago, but maybe there has been an update to this, since we would also like to do automatic error reporting

Is there nowadays a way to override exception handling basically for any python code executed within Houdini. It could be within
* Shelftools
* Python nodes
* HDAmodules
* Node/Parm callbacks
* ...


Hooking into
houdiniInterpreter.HoudiniConsole.showtraceback
for the Python shell worked, but no success so far for any of the other topics.

I also tried overriding the following:
sys.excepthook
houdiniInterpreter.code.sys.excepthook
houdiniInterpreter.sys.excepthook

Any input would be appreciated!

Cheers!
Edited by shadesoforange - 2023年3月31日 03:51:33
Manuel Köster - Senior Technical Artist @Remedy Entertainment

https://www.remedygames.com/ [www.remedygames.com]
http://shadesoforange.de/ [shadesoforange.de]
https://twitter.com/ShadesOfOrange_ [twitter.com]
  • Quick Links