Colab DisabledErrorFunction Error handling

Viewed 204

So I get that google colab crashes when using cv2.imshow for displaying images. Google colab has its own solution for replacing that function and google.colab.patches import cv2_imshow can be used as a replacement for displaying images.

However, I did notice that colab raises a DisabledFunctionError when I try using cv2.imshow. This led me to think that maybe I can try catching that error using 'Try and Except' block. But in order to do that DisabledFunctionError must be defined as a custom error in python. So I wrote an exception class to define that error:

class DisabledFunctionError(Exception):
  pass

Now having done that I should assume that an error can be handled using try and except block as follows:

try:
  cv2.imshow(frame, image)
except DisabledErrorFunction:
  print('Error handled')

But, to my surprise, colab still raises an exception and its not caught by the try and except block. This behavior seems strange to me. Am I missing something here? Is this behavior due to colab?

0 Answers
Related