-
Notifications
You must be signed in to change notification settings - Fork 121
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