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: f12e72197464
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: 77a7e592cb88
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jan 13, 2015

  1. Copy the full SHA
    2029613 View commit details
  2. Copy the full SHA
    77a7e59 View commit details
Showing with 27 additions and 25 deletions.
  1. +2 −0 artiq/management/scheduler.py
  2. +25 −25 artiq/management/sync_struct.py
2 changes: 2 additions & 0 deletions artiq/management/scheduler.py
Original file line number Diff line number Diff line change
@@ -115,3 +115,5 @@ def _schedule(self):
],
timeout=next_periodic,
return_when=asyncio.FIRST_COMPLETED)
for t in pend:
t.cancel()
50 changes: 25 additions & 25 deletions artiq/management/sync_struct.py
Original file line number Diff line number Diff line change
@@ -72,9 +72,9 @@ def _receive_cr(self):


class Notifier:
def __init__(self, backing_struct, publisher=None, path=[]):
def __init__(self, backing_struct, publish=None, path=[]):
self.read = backing_struct
self.publisher = publisher
self.publish = publish
self._backing_struct = backing_struct
self._path = path

@@ -83,44 +83,44 @@ def __init__(self, backing_struct, publisher=None, path=[]):

def append(self, x):
self._backing_struct.append(x)
if self.publisher is not None:
self.publisher.publish(self, {"action": "append",
"path": self._path,
"x": x})
if self.publish is not None:
self.publish(self, {"action": "append",
"path": self._path,
"x": x})

def insert(self, i, x):
self._backing_struct.insert(i, x)
if self.publisher is not None:
self.publisher.publish(self, {"action": "insert",
"path": self._path,
"i": i, "x": x})
if self.publish is not None:
self.publish(self, {"action": "insert",
"path": self._path,
"i": i, "x": x})

def pop(self, i=-1):
r = self._backing_struct.pop(i)
if self.publisher is not None:
self.publisher.publish(self, {"action": "pop",
"path": self._path,
"i": i})
if self.publish is not None:
self.publish(self, {"action": "pop",
"path": self._path,
"i": i})
return r

def __setitem__(self, key, value):
self._backing_struct.__setitem__(key, value)
if self.publisher is not None:
self.publisher.publish(self, {"action": "setitem",
"path": self._path,
"key": key,
"value": value})
if self.publish is not None:
self.publish(self, {"action": "setitem",
"path": self._path,
"key": key,
"value": value})

def __delitem__(self, key):
self._backing_struct.__delitem__(key)
if self.publisher is not None:
self.publisher.publish(self, {"action": "delitem",
"path": self._path,
"key": key})
if self.publish is not None:
self.publish(self, {"action": "delitem",
"path": self._path,
"key": key})

def __getitem__(self, key):
item = getitem(self._backing_struct, key)
return Notifier(item, self.publisher, self._path + [key])
return Notifier(item, self.publish, self._path + [key])


class Publisher(AsyncioServer):
@@ -131,7 +131,7 @@ def __init__(self, notifiers):
self._notifier_names = {id(v): k for k, v in notifiers.items()}

for notifier in notifiers.values():
notifier.publisher = self
notifier.publish = self.publish

@asyncio.coroutine
def _handle_connection_cr(self, reader, writer):