Skip to content

Commit

Permalink
Fix the logging disabler
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTyton committed May 28, 2024
1 parent c554392 commit e02dd26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion release-versions/latest.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.05.27-12
2024.05.27-13
20 changes: 8 additions & 12 deletions root/app/url_ingester.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ def set_timeout(time):
yield
finally:
socket.setdefaulttimeout(old_timeout)

@contextmanager
def set_logging_level():
"""Set the logging level to CRITICAL."""
old_level = logging.root.manager.disable
logging.disable(logging.CRITICAL)
try:
yield
finally:
logging.disable(old_level)

class EmailInfo:
"""
Expand Down Expand Up @@ -68,14 +58,20 @@ def get_urls(self) -> set[str]:
"""
urls = set()
# Save the current logging level
old_level = logging.root.manager.disable

# Set the logging level to CRITICAL
logging.disable(logging.CRITICAL)
with set_timeout(55):
try:
# Get URLs from the email account
with set_logging_level():
urls = geturls.get_urls_from_imap(self.server, self.email, self.password, self.mailbox)
urls = geturls.get_urls_from_imap(self.server, self.email, self.password, self.mailbox)
except Exception as e:
logging.disable(old_level)
ff_logging.log_failure(f"Failed to get URLs: {e}")
finally:
# Restore the old logging level
logging.disable(old_level)
return urls


Expand Down

0 comments on commit e02dd26

Please sign in to comment.