Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8979d9d5e7c1
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: aba749093b31
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Feb 6, 2015

  1. Copy the full SHA
    0d0a05a View commit details
  2. Copy the full SHA
    aba7490 View commit details
Showing with 28 additions and 14 deletions.
  1. +14 −2 artiq/frontend/artiq_ctlmgr.py
  2. +13 −11 artiq/protocols/sync_struct.py
  3. +1 −1 examples/ddb.pyon
16 changes: 14 additions & 2 deletions artiq/frontend/artiq_ctlmgr.py
Original file line number Diff line number Diff line change
@@ -28,8 +28,15 @@ def get_argparser():


class Controllers:
def __init__(self):
self.host_filter = None

def __setitem__(self, k, v):
print("set {} {}".format(k, v))
if (isinstance(v, dict) and v["type"] == "controller"
and v["host"] == self.host_filter):
command = v["command"].format(bind=self.host_filter,
port=v["port"])
print("start controller {}: {}".format(k, command))

def __delitem__(self, k):
print("del {}".format(k))
@@ -64,8 +71,13 @@ def main():
subscriber = Subscriber("devices", controller_db.sync_struct_init)
while True:
try:
def set_host_filter():
s = subscriber.writer.get_extra_info("socket")
localhost = s.getsockname()[0]
controller_db.current_controllers.host_filter = localhost
loop.run_until_complete(
subscriber.connect(args.server, args.port))
subscriber.connect(args.server, args.port,
set_host_filter))
try:
loop.run_until_complete(subscriber.receive_task)
finally:
24 changes: 13 additions & 11 deletions artiq/protocols/sync_struct.py
Original file line number Diff line number Diff line change
@@ -64,17 +64,19 @@ def __init__(self, notifier_name, target_builder, notify_cb=None):
self.notify_cb = notify_cb

@asyncio.coroutine
def connect(self, host, port):
self._reader, self._writer = \
def connect(self, host, port, before_receive_cb=None):
self.reader, self.writer = \
yield from asyncio.open_connection(host, port)
try:
self._writer.write(_init_string)
self._writer.write((self.notifier_name + "\n").encode())
if before_receive_cb is not None:
before_receive_cb()
self.writer.write(_init_string)
self.writer.write((self.notifier_name + "\n").encode())
self.receive_task = asyncio.Task(self._receive_cr())
except:
self._writer.close()
del self._reader
del self._writer
self.writer.close()
del self.reader
del self.writer
raise

@asyncio.coroutine
@@ -86,15 +88,15 @@ def close(self):
except asyncio.CancelledError:
pass
finally:
self._writer.close()
del self._reader
del self._writer
self.writer.close()
del self.reader
del self.writer

@asyncio.coroutine
def _receive_cr(self):
targets = []
while True:
line = yield from self._reader.readline()
line = yield from self.reader.readline()
if not line:
return
mod = pyon.decode(line.decode())
2 changes: 1 addition & 1 deletion examples/ddb.pyon
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@
"host": "::1",
"port": 3253,
"target_name": "lda",
"command": "lda_controller -p {port} -d sim"
"command": "lda_controller -p {port} --bind {bind} -d sim"
},

"pmt": "pmt0",