Skip to content

Commit

Permalink
cleaner checks for lookup failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Bibhas committed Mar 26, 2018
1 parent 68cb42e commit de9aadf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions baseframe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ def is_public_email_domain(email_or_domain, default=None, timeout=30):
# Cache entry missing or corrupted; fetch a new result and update cache
try:
sniffedmx = mxsniff(email_or_domain, timeout=timeout)
asset_cache.set(cache_key, sniffedmx, timeout=86400)
except MXLookupException as e:
# Domain lookup failed
if default is None:
raise e
asset_cache.set(cache_key, sniffedmx, timeout=86400)

if sniffedmx is not None and any([p['public'] for p in sniffedmx['providers']]):
if sniffedmx is None:
# Domain lookup failed
return default
elif any([p['public'] for p in sniffedmx['providers']]):
return True
else:
# in that case return default
return default
return False

0 comments on commit de9aadf

Please sign in to comment.