[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-bugs] #13774 [Stem]: Mention pickling in "Mirror Mirror on the Wall"?
#13774: Mention pickling in "Mirror Mirror on the Wall"?
-----------------------------+----------------------------------------
Reporter: mmcc | Owner: atagar
Type: enhancement | Status: new
Priority: trivial | Milestone:
Component: Stem | Version:
Resolution: | Keywords: Stem, Python, pickle, docs
Actual Points: | Parent ID:
Points: |
-----------------------------+----------------------------------------
Comment (by atagar):
Hi mmcc. The purpose of the DescriptorDownloader is to get the current
descriptors. As for saving them to disk and reloading them personally I'd
just dump the descriptor...
{{{
with open('/path/to/persist/it', 'w') as dump_file:
dump_file.write(str(my_descriptor))
}}}
Then assuming that it's, say, a server descriptor you'd load it like...
{{{
from stem.descriptor import parse_file
with open('/path/to/persist/it') as dump_file:
my_descriptor = parse_file(dump_file, 'server-descriptor 1.0')
}}}
(this is just off the top of my head - no promises the above doesn't have
a typo)
I suppose pickling might have an advantage in terms of space or read time
(... or could be worse in those regards - would need some testing), but
regardless I'd trust the above a tad more.
All that said, adding a section on persisting and reloading descriptors
sounds like a fine idea. Let me know if you can think of a compelling
reason to do pickling rather than the above.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/13774#comment:1>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs