[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/develop] Workaround strange file descriptor issue in Stem.
commit f59121dc25a256ae9e24f65d0e29ea4109ab102a
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Fri Aug 29 09:58:09 2014 +0000
Workaround strange file descriptor issue in Stem.
For reasons I am unable as of yet to determine, if I call
`stem.descriptor.router_status_entry._parse_file()` with its `start_position`
parameter, giving it the byte offset in the file to start reading at, as well
as the file descriptor itself, that Stem function does *not* reliably `seek()`
to that byte offset in the file.
The failure results of the last commit, e47247869, can be seen here:
https://travis-ci.org/isislovecruft/bridgedb/jobs/33874252
The fix -- don't ask me why it works, although I suspect either the scoping of
Python's `with` syntax or some issue with passing file descriptors from an
asynchronous program to a blocking one -- is to call `seek()` before passing
the file descriptor.
---
lib/bridgedb/parse/descriptors.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/bridgedb/parse/descriptors.py b/lib/bridgedb/parse/descriptors.py
index 5028ad3..49d6e8a 100644
--- a/lib/bridgedb/parse/descriptors.py
+++ b/lib/bridgedb/parse/descriptors.py
@@ -59,8 +59,8 @@ def parseNetworkStatusFile(filename, validate=True, skipHeaders=True,
while not fh.readline().startswith('r '):
position = fh.tell()
logging.debug("Skipping %d bytes of networkstatus file." % position)
- document = _parseNSFile(fh, validate, entry_class=descriptorClass,
- start_position=position)
+ fh.seek(position)
+ document = _parseNSFile(fh, validate, entry_class=descriptorClass)
routers.extend(list(document))
logging.info("Closed networkstatus file: %s" % filename)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits