Permalink
Browse files

better dealings with exceptions in pmt rpc

  • Loading branch information...
1 parent 6fb562d commit dfae3f1c7e04cf59b3d407592d5c190e8aee1b0c @guruofquality committed Oct 4, 2012
Showing with 9 additions and 3 deletions.
  1. +4 −3 python/pmt_rpc.py
  2. +5 −0 python/qa_pmt_rpc.py
View
@@ -67,7 +67,8 @@ def work(self, input_items, output_items):
try: msg = self.pop_msg_queue()
except: return -1
result = self.handle_request(pmt.to_python(msg.key), pmt.to_python(msg.value))
- msg.value = pmt.from_python(result)
+ try: msg.value = pmt.from_python(result)
+ except Exception as ex: msg.value = pmt.from_python(str(ex))
if self._result_msg: self.post_msg(0, msg)
def handle_request(self, fcn_name, request):
@@ -92,8 +93,8 @@ def handle_request(self, fcn_name, request):
#try to execute the request
try:
ret = fcn_ptr(*args, **kwargs)
- except:
- err = 'cannot execute request for %s, expected tuple of args, kwargs'%fcn_name
+ except Exception as ex:
+ err = 'cannot execute request for %s, got error %s'%(fcn_name, ex)
return request, None, err
#return the sucess result
View
@@ -40,6 +40,9 @@ def __init__(self):
has_msg_input = True,
)
+ def test_print(self, arg):
+ print arg
+
def work(self, input_items, output_items):
self.post_msg(0, pmt.from_python("multx2"), pmt.from_python(((42,), None)))
@@ -52,6 +55,8 @@ def work(self, input_items, output_items):
print(result)
assert(result == 42*2)
+ self.post_msg(0, pmt.from_python("_control_block.test_print"), pmt.from_python((('hello',), None)))
+
return -1
class my_top_block(gr.top_block):

0 comments on commit dfae3f1

Please sign in to comment.