From d78482474fbc2b9cd92b4d0b23c492454647263c Mon Sep 17 00:00:00 2001 From: Bohdan Marukhnenko Date: Sat, 28 Oct 2023 12:20:03 +0300 Subject: [PATCH 1/3] Added custom inbox update interval support --- tempmail/providers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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') From fb25d66b6b0127a6436986009cca3a0405e1231a Mon Sep 17 00:00:00 2001 From: Bohdan Marukhnenko Date: Sat, 28 Oct 2023 12:20:38 +0300 Subject: [PATCH 2/3] Bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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', From 9dbe8281b43c5eb3da77afa1bac842273e1db156 Mon Sep 17 00:00:00 2001 From: Bohdan Marukhnenko Date: Sat, 28 Oct 2023 12:30:46 +0300 Subject: [PATCH 3/3] Added OneSecMail.inbox_update_interval to docs --- README.md | 3 +++ 1 file changed, 3 insertions(+) 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)