Commit eb78c5d2 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent adab4a66
......@@ -962,14 +962,33 @@ def watch(twlink, zf, at, pinok=None): # XXX -> ?
w.at = at
assert w.pinned == twlink._pinAt(zf, at)
# stop_watch instructs wlink to stop watching the file.
@func(tWatchLink)
def stop_watch(twlink, zf):
assert zf in twlink._watching
w = twlink._watching.pop(zf)
twlink._watch(zf, b"-", {}, "ok")
w.at = z64
w.pinned = {}
# _watch sends watch request for zf@at, expects initial pins specified by pinok and final reply.
#
# at also can be b"-" which means "stop watching"
#
# pinok: {} blk -> at that have to be pinned.
# if replyok ends with '…' only reply prefix until the dots is checked.
@func(tWatchLink)
def _watch(twlink, zf, at, pinok, replyok):
if at == b"-":
xat = at
else:
xat = b"@%s" % h(at)
def _(ctx, ev):
reply = twlink.sendReq(ctx, b"watch %s @%s" % (h(zf._p_oid), h(at)))
reply = twlink.sendReq(ctx, b"watch %s %s" % (h(zf._p_oid), xat))
if replyok.endswith('…'):
rok = replyok[:-len('…')]
assert reply[:len(rok)] == rok
......@@ -1285,8 +1304,8 @@ def test_wcfs():
t.dump_history()
#wl3_.watch(zf, "-") XXX enable
wl2.close() # wl2 should not be notified because it was closed
wl3_.stop_watch(zf) # w3_ should not be notified
wl2.close() # wl2:* should not be notified because it was closed
def w_assertPin(pinw3):
assert w3.pinned == pinw3
assert w3_.pinned == {}; assert w3_.at == z64 # wl3_ unsubscribed from zf
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment