coredevice: do not desync kernel TCP stream on RPCReturnValueError.

And propagate the error upwards instead of trying to squeeze it
through the core device in futility.
This commit is contained in:
whitequark 2017-06-25 04:47:32 +00:00
parent fdb24ef139
commit 31b52ff1b3
2 changed files with 30 additions and 5 deletions

View File

@ -524,6 +524,8 @@ class CommKernel:
self._write_header(_H2DMsgType.RPC_REPLY)
self._write_bytes(return_tags)
self._send_rpc_value(bytearray(return_tags), result, result, service)
except RPCReturnValueError as exn:
raise
except Exception as exn:
logger.debug("rpc service: %d %r %r ! %r", service_id, args, kwargs, exn)

View File

@ -3,6 +3,7 @@ from time import sleep
from artiq.experiment import *
from artiq.test.hardware_testbench import ExperimentCase
from artiq.coredevice.comm_kernel import RPCReturnValueError
class _Roundtrip(EnvExperiment):
@ -96,6 +97,12 @@ class _RPCTypes(EnvExperiment):
def return_str(self) -> TStr:
return "foo"
def return_bytes(self) -> TBytes:
return b"foo"
def return_bytearray(self) -> TByteArray:
return bytearray(b"foo")
def return_tuple(self) -> TTuple([TInt32, TInt32]):
return (1, 2)
@ -105,6 +112,9 @@ class _RPCTypes(EnvExperiment):
def return_range(self) -> TRange32:
return range(10)
def return_mismatch(self):
return b"foo"
@kernel
def run_recv(self):
core_log(self.return_bool())
@ -112,6 +122,8 @@ class _RPCTypes(EnvExperiment):
core_log(self.return_int64())
core_log(self.return_float())
core_log(self.return_str())
core_log(self.return_bytes())
core_log(self.return_bytearray())
core_log(self.return_tuple())
core_log(self.return_list())
core_log(self.return_range())
@ -126,20 +138,31 @@ class _RPCTypes(EnvExperiment):
self.accept(0x100000000)
self.accept(1.0)
self.accept("foo")
self.accept(b"foo")
self.accept(bytearray(b"foo"))
self.accept((2, 3))
self.accept([1, 2])
self.accept(range(10))
self.accept(self)
def run(self):
self.run_send()
self.run_recv()
@kernel
def run_mismatch(self):
self.return_mismatch()
class RPCTypesTest(ExperimentCase):
def test_args(self):
def test_send(self):
exp = self.create(_RPCTypes)
exp.run()
exp.run_send()
def test_recv(self):
exp = self.create(_RPCTypes)
exp.run_send()
def test_mismatch(self):
exp = self.create(_RPCTypes)
with self.assertRaises(RPCReturnValueError):
exp.run_mismatch()
class _RPCCalls(EnvExperiment):