Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean proxy in logs #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions rotating_proxies/expire.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ def get_proxy(self, proxy_address):
def mark_dead(self, proxy, _time=None):
""" Mark a proxy as dead """
if proxy not in self.proxies:
logger.warn("Proxy <%s> was not found in proxies list" % proxy)
logger.warn("Proxy <%s> was not found in proxies list" % self._clean_proxy(proxy))
return

if proxy in self.good:
logger.debug("GOOD proxy became DEAD: <%s>" % proxy)
logger.debug("GOOD proxy became DEAD: <%s>" % self._clean_proxy(proxy))
else:
logger.debug("Proxy <%s> is DEAD" % proxy)
logger.debug("Proxy <%s> is DEAD" % self._clean_proxy(proxy))

self.unchecked.discard(proxy)
self.good.discard(proxy)
Expand All @@ -88,11 +88,11 @@ def mark_dead(self, proxy, _time=None):
def mark_good(self, proxy):
""" Mark a proxy as good """
if proxy not in self.proxies:
logger.warn("Proxy <%s> was not found in proxies list" % proxy)
logger.warn("Proxy <%s> was not found in proxies list" % self._clean_proxy(proxy))
return

if proxy not in self.good:
logger.debug("Proxy <%s> is GOOD" % proxy)
logger.debug("Proxy <%s> is GOOD" % self._clean_proxy(proxy))

self.unchecked.discard(proxy)
self.dead.discard(proxy)
Expand All @@ -118,6 +118,10 @@ def reset(self):
self.dead.remove(proxy)
self.unchecked.add(proxy)

def _clean_proxy(self, proxy):
""" Clean proxy so that it can be safely used in logs """
return extract_proxy_hostport(proxy)

@property
def mean_backoff_time(self):
if not self.dead:
Expand Down