diff --git a/README.md b/README.md index 86e2835..2890aa5 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,9 @@ email = OneSecMail() # request_email(email=email.address) +# Speed up inbox refresh rate +OneSecMail.inbox_update_interval = 0.1 # every 100ms + # Accept only emails with a specific subject, raise error after 60 seconds msg = email.wait_for_message(timeout=60, filter=lambda m: m.subject == 'Hello World!') print(msg.body) diff --git a/setup.py b/setup.py index 3ca0457..0b6ed11 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ def read(path: str) -> str: setup( name='tempmail-python', - version='2.3.0', + version='2.3.1', description='Python library for generating and managing temporary email addresses.', long_description=read('README.md'), long_description_content_type='text/markdown', diff --git a/tempmail/providers.py b/tempmail/providers.py index 7ef3388..b7efbb6 100644 --- a/tempmail/providers.py +++ b/tempmail/providers.py @@ -13,6 +13,9 @@ class OneSecMail: """1secmail.com API wrapper""" + inbox_update_interval = 0.5 + """How often to update the inbox in seconds""" + def __init__(self, address: str | None = None, username: str | None = None, domain: str | None = None) -> None: """Create a new 1secmail.com email address @@ -67,7 +70,7 @@ def wait_for_message(self, timeout: int | None = 60, filter: callable = lambda _ for msg_info in inbox: if filter(msg_info.message): return msg_info.message - time.sleep(1) + time.sleep(OneSecMail.inbox_update_interval) raise TimeoutError('Timed out waiting for message')