try:
    myapp.foo.doSomething()
except Exception as e:
    exc_type, exc_value, exc_tb = sys.exc_info()
filename, line_num, func_name, text = traceback.extract_tb(exc_tb)[-1]
print('Thrown from: %s' % filename)
Найти имя модуля исходного исключения в Python