kakshay21 / verify_email

verify-email can verify any email address by efficiently checking the domain name and pinging the handler to verify its existence.
https://pypi.org/project/verify-email/
MIT License
132 stars 32 forks source link

There is no current event loop in thread 'Thread-1 (process_request_thread)'. #48

Closed mahiuddin-dev closed 12 months ago

mahiuddin-dev commented 1 year ago
from django.shortcuts import render
from verify_email import verify_email

def index(request):
    email = 'example@foo.com'
    valid = verify_email(email)
    return render(request,'index.html')

It's not working when i want to do it in Django. But if i want to do it in just in a python file then it's working fine. Like i create a new.py file then write

from verify_email import verify_email

print(verify_email('example@gmail.com'))

It return fine. So why not it's working on my django application.

afsar47 commented 1 year ago

this problem is not related to verify_email package are you using a web server like Django and Flask so you should be register loop event like this

import asyncio
 asyncio.set_event_loop(asyncio.new_event_loop())
           for row in data.itertuples():

            try:
                print(row.Email)
                emails.append(row.Email)
                verified_emails.append(verify_email(row.Email))
            except Exception as e:
                print(e)

it's work for me