I'm running a little toy script that kinda sorta behaves like sbws in hopes that I can reproduce this. I have been doing so for 24 hours or so now.
I'm also running sbws 0.4.2-dev through a very limited Tor client with BandwidthRate 500 KBytes set, and have been doing so for 24 hours.
I'm doing all of this with Python 3.4.8, 3.5.3, and 3.6.5.
I will do this for a few more days. If I don't get these errors, I will switch sbws to the version it was at when these KeyErrors were happening. Of note, at that time we were getting exit policies from micro descriptors but now we get them from server descriptors.
The huge difference in the numbers is because I ran these for vastly different amounts of time. 3.5.1 is not 3 orders of magnitude more buggy than 3.5.0. 3.5.4 ran for 24 hours and didn't display the issue; 3.5.0 ran for 2 minutes and displayed the issue.
Example unhelpful traceback that the above grep is searching for.
[2018-07-10 10:42:47,961] [sbws.lib.relaylist] [ERROR] Got that KeyError in stem again...: (<stem.exit_policy.ExitPolicy object at 0x7f9fe6f656d8>, <object object at 0x7fa01e24b080>, ('port', 80))Traceback (most recent call last): File "/home/matt/src/simple-bw-scanner/sbws/lib/relaylist.py", line 167, in exits_can_exit_to if policy is not None and policy.can_exit_to(port=port):
atagar: based on these findings I recommend using stem's lru_cache for python 3.5.0-3.5.3. Or ... figuring out why getting exit policies from microdescriptors doesn't play nicely with python's lru_cache in only a couple versions of python.
Switching back to new because I no longer think this needs_information.
In case it is useful, i paste traceback lines including the lines where the exception is raised in stem (python 3.5.3):
File "/path/simple-bw-scanner/sbws/lib/relaylist.py", line 120, in can_exit_to return self.exit_policy.can_exit_to(host, port) File "/path/.virtualenvs/simplebwscanner3/lib/python3.5/site-packages/stem-1.6.0.dev0-py3.5.egg/stem/exit_policy.py", line 294, in can_exit_to if rule.is_match(address, port, strict): File "/path/.virtualenvs/simplebwscanner3/lib/python3.5/site-packages/stem-1.6.0.dev0-py3.5.egg/stem/exit_policy.py", line 783, in is_match comparison_addr_bin &= self._get_mask_bin()KeyError: (<stem.exit_policy.ExitPolicyRule object at 0x7f3743f70a90>,)[2018-07-14 14:55:23,007] [sbws.core.scanner] [ERROR] Unhandled exception caught while measuring Unnamed: <class 'KeyError'> (<stem.exit_policy.ExitPolicyRule object at 0x7f3743f70a90>,
Hi juga. As previously mentioned I'm willing to cut a single release for sbws if/when pastly would like it. If now's the time then great, but please have him chime in that he's certain this is when he wants it.