Package: txtorcon Version: 0.15.0-1 Tags: patch I noticed this issue because the package fail to build reproducably, and sphinx generate documentation where the now statement below is replaced with a concrete timestamp. See <URL: > for the details about this.
But while looking at the code, it occured to me that it probably is not working as the author intended. If I remember correctly (based on a blog post from Chris Lamb[1]), the default function arguments in Python are evaluated when the code is parsed (ie when the 'import' statements are evaluated). The effect of this is that the age() function is not give a fresh new timestamp generated at call time, but the timestamp generated when the file was imported. [1] <URL: https://chris-lamb.co.uk/posts/python-quirk-signatures-are-evaluated-import-time > I suspect the author wanted fresh timestamp, and suggest to rewrite the age() function like this to make sure age() without any now value specified actually uses a fresh timestamp: diff --git a/txtorcon/circuit.py b/txtorcon/circuit.py index 5166fc1..cd9a3cf 100644 --- a/txtorcon/circuit.py +++ b/txtorcon/circuit.py @@ -157,7 +157,7 @@ class Circuit(object): d.addCallback(close_command_is_queued) return self._closing_deferred - def age(self, now=datetime.datetime.utcnow()): + def age(self, now=None): """ Returns an integer which is the difference in seconds from 'now' to when this circuit was created. @@ -166,6 +166,8 @@ class Circuit(object): """ if not self.time_created: return None + if now == None: + now = datetime.datetime.utcnow() return (now - self.time_created).seconds def _create_flags(self, kw): -- Happy hacking Petter Reinholdtsen