forked from M-Labs/artiq
1
0
Fork 0

ddb: support for best effort RPC client

This commit is contained in:
Sebastien Bourdeauducq 2015-02-12 00:54:54 +08:00
parent 1b3603d8bf
commit 39dfbb4162
2 changed files with 8 additions and 3 deletions

View File

@ -5,7 +5,7 @@ import numpy
import h5py import h5py
from artiq.protocols.sync_struct import Notifier from artiq.protocols.sync_struct import Notifier
from artiq.protocols.pc_rpc import Client from artiq.protocols.pc_rpc import Client, BestEffortClient
_type_to_hdf5 = { _type_to_hdf5 = {
@ -79,7 +79,11 @@ def _create_device(desc, dbh):
device_class = getattr(module, desc["class"]) device_class = getattr(module, desc["class"])
return device_class(dbh, **desc["arguments"]) return device_class(dbh, **desc["arguments"])
elif ty == "controller": elif ty == "controller":
return Client(desc["host"], desc["port"], desc["target_name"]) if desc["best_effort"]:
cl = BestEffortClient
else:
cl = Client
return cl(desc["host"], desc["port"], desc["target_name"])
else: else:
raise ValueError("Unsupported type in device DB: " + ty) raise ValueError("Unsupported type in device DB: " + ty)
@ -119,7 +123,7 @@ class DBHub:
""" """
for dev in reversed(list(self.active_devices.values())): for dev in reversed(list(self.active_devices.values())):
if isinstance(dev, Client): if isinstance(dev, (Client, BestEffortClient)):
dev.close_rpc() dev.close_rpc()
elif hasattr(dev, "close"): elif hasattr(dev, "close"):
dev.close() dev.close()

View File

@ -84,6 +84,7 @@
"lda": { "lda": {
"type": "controller", "type": "controller",
"best_effort": true,
"host": "::1", "host": "::1",
"port": 3253, "port": 3253,
"target_name": "lda", "target_name": "lda",