X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/blobdiff_plain/690a6ec147f76213263b58a8a7fd82b28dde349a..fe2a5dcf9de1f124ed3cfa2c6327860bd5aca820:/py/tripe.py.in diff --git a/py/tripe.py.in b/py/tripe.py.in index 2e21885b..c2b430be 100644 --- 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 + if _debug: print '* %s' % me _Coroutine.switch(me, *args, **kw) + if _debug: print '* %s' % rootcr ###-------------------------------------------------------------------------- ### 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)) +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.""" - defer(lambda: Coroutine(func).switch(*args, **kw)) + defer(lambda: (Coroutine(func, name = funargstr(func, args, kw)) + .switch(*args, **kw))) ## Asides. _asideq = Queue() @@ -702,7 +711,9 @@ class TripeCommandDispatcher (TripeConnection): 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 @@ -819,13 +830,16 @@ class TripeCommandDispatcher (TripeConnection): def add(me, peer, *addr, **kw): return _simple(me.command(bg = True, *['ADD'] + - _kwopts(kw, ['tunnel', 'keepalive', 'cork']) + + _kwopts(kw, ['tunnel', 'keepalive', + 'key', 'priv', 'cork', + 'mobile']) + [peer] + list(addr))) def addr(me, peer): return _oneline(me.command('ADDR', peer)) - def algs(me): - return _keyvals(me.command('ALGS')) + def algs(me, peer = None): + return _keyvals(me.command('ALGS', + *((peer is not None and [peer]) or []))) def checkchal(me, chal): return _simple(me.command('CHECKCHAL', chal)) def daemon(me):