Merge pull request #445 from eendebakpt/feat/remotewarning

add warnings for remote exceptions
This commit is contained in:
Ogi Moore 2019-06-10 08:53:06 -07:00 committed by GitHub
commit 10328817c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
import os, time, sys, traceback, weakref import os, time, sys, traceback, weakref
import numpy as np import numpy as np
import threading import threading
import warnings
try: try:
import __builtin__ as builtins import __builtin__ as builtins
import cPickle as pickle import cPickle as pickle
@ -21,6 +22,9 @@ class NoResultError(Exception):
because the call has not yet returned.""" because the call has not yet returned."""
pass pass
class RemoteExceptionWarning(UserWarning):
"""Emitted when a request to a remote object results in an Exception """
pass
class RemoteEventHandler(object): class RemoteEventHandler(object):
""" """
@ -499,9 +503,9 @@ class RemoteEventHandler(object):
#print ''.join(result) #print ''.join(result)
exc, excStr = result exc, excStr = result
if exc is not None: if exc is not None:
print("===== Remote process raised exception on request: =====") warnings.warn("===== Remote process raised exception on request: =====", RemoteExceptionWarning)
print(''.join(excStr)) warnings.warn(''.join(excStr), RemoteExceptionWarning)
print("===== Local Traceback to request follows: =====") warnings.warn("===== Local Traceback to request follows: =====", RemoteExceptionWarning)
raise exc raise exc
else: else:
print(''.join(excStr)) print(''.join(excStr))