~mdw
/
tripe
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
New peer option `-mobile': follow rapid IP address and port changes.
[tripe]
/
py
/
tripe.py.in
diff --git
a/py/tripe.py.in
b/py/tripe.py.in
index
2e21885
..
cefb667
100644
(file)
--- a/
py/tripe.py.in
+++ b/
py/tripe.py.in
@@
-128,7
+128,9
@@
class Coroutine (_Coroutine):
"""
def switch(me, *args, **kw):
assert _Coroutine.getcurrent() is rootcr
"""
def switch(me, *args, **kw):
assert _Coroutine.getcurrent() is rootcr
+ if _debug: print '* %s' % me
_Coroutine.switch(me, *args, **kw)
_Coroutine.switch(me, *args, **kw)
+ if _debug: print '* %s' % rootcr
###--------------------------------------------------------------------------
### Default places for things.
###--------------------------------------------------------------------------
### Default places for things.
@@
-610,9
+612,16
@@
def defer(func, *args, **kw):
"""Call FUNC(*ARGS, **KW) later, in the root coroutine."""
_deferq.append((func, args, kw))
"""Call FUNC(*ARGS, **KW) later, in the root coroutine."""
_deferq.append((func, args, kw))
+def funargstr(func, args, kw):
+ items = [repr(a) for a in args]
+ for k, v in kw.iteritems():
+ items.append('%s = %r' % (k, v))
+ return '%s(%s)' % (func.__name__, ', '.join(items))
+
def spawn(func, *args, **kw):
"""Call FUNC, passing ARGS and KW, in a fresh coroutine."""
def spawn(func, *args, **kw):
"""Call FUNC, passing ARGS and KW, in a fresh coroutine."""
- defer(lambda: Coroutine(func).switch(*args, **kw))
+ defer(lambda: (Coroutine(func, name = funargstr(func, args, kw))
+ .switch(*args, **kw)))
## Asides.
_asideq = Queue()
## Asides.
_asideq = Queue()
@@
-702,7
+711,9
@@
class TripeCommandDispatcher (TripeConnection):
global _deferq
assert _Coroutine.getcurrent() is rootcr
global _deferq
assert _Coroutine.getcurrent() is rootcr
- Coroutine(_runasides).switch()
+ Coroutine(_runasides, name = '_runasides').switch()
+ if quitp is None:
+ quitp = me.quitp
while not quitp():
while _deferq:
q = _deferq
while not quitp():
while _deferq:
q = _deferq
@@
-819,7
+830,8
@@
class TripeCommandDispatcher (TripeConnection):
def add(me, peer, *addr, **kw):
return _simple(me.command(bg = True,
*['ADD'] +
def add(me, peer, *addr, **kw):
return _simple(me.command(bg = True,
*['ADD'] +
- _kwopts(kw, ['tunnel', 'keepalive', 'cork']) +
+ _kwopts(kw, ['tunnel', 'keepalive',
+ 'key', 'cork', 'mobile']) +
[peer] +
list(addr)))
def addr(me, peer):
[peer] +
list(addr)))
def addr(me, peer):