JoshData / JoshData/python-email-validator
DNS resolver can run for longer than the given timeout
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 140
- PR merge metrics
- No merged PRs in 30d
Description
It's very hard to reproduce, we found the problem because we have a 60s timeout for our web server that we kept busting, even with email-validator's default 15s timeout.
Disabling check_availability solved our problem.
The problem
The problem lies within:
response = dns_resolver.resolve(domain, "MX")
( https://github.com/JoshData/python-email-validator/blob/main/email_validator/deliverability.py#L40 )
While debugging, what I can see is that the resolver goes through a loop, and only checks the timeout between calls. It also does some time.sleep()
That means that if a call or a sleep is longer than the timeout, it doesn't get interrupted and can thus run for longer
The solution
Using signal, we could interrupt the process. See https://stackoverflow.com/a/494273
This package does it: https://github.com/pnpnpn/timeout-decorator
I'll try implementing the stackoverflow suggestion on my end and write back with news
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in deliverability.py at the dns_resolver.resolve(domain, "MX") call and trace how the configured timeout is passed through when check_availability is enabled. Reproduce or investigate the resolver loop and sleep behavior described in the issue. Done means DNS resolution does not run beyond the given timeout, with the existing deliverability behavior preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100