verify_email icon indicating copy to clipboard operation
verify_email copied to clipboard

Doesn't work with FastApi already running eventloop

Open syleishere opened this issue 4 years ago • 6 comments

File "/usr/local/lib/python3.9/site-packages/verify_email/verify_email.py", line 106, in verify_email resp = loop.run_until_complete(_verify_email(email, timeout, verify))

RuntimeError: this event loop is already running.

CODE:

if not await verify_email(email):
        raise HTTPException(status_code=HTTP_403_FORBIDDEN, detail="Invalid Email")

syleishere avatar Apr 12 '21 14:04 syleishere

Hi @syleishere, I'm curious if you can use it like shown in https://github.com/kakshay21/verify_email/blob/1b641d2867d1c7198b2cf46e21bc75737dcad273/examples.py#L39 Otherwise, let me know, I'll try to find some other workaround for this. Thanks!

kakshay21 avatar May 15 '21 10:05 kakshay21

Or if you're not using bulk email verify then this should work for you: https://github.com/kakshay21/verify_email/blob/1b641d2867d1c7198b2cf46e21bc75737dcad273/verify_email/verify_email.py#L77

kakshay21 avatar May 15 '21 12:05 kakshay21

It wouldn't work, I have already fought with getting aiomysql working in fastapi. Issue is there is only one way to get access to eventloop with it, and that's with a startup function they created. So unless plugin comes with some initialization code to call, it would have to be integrated right in. I learned they do have an email validation tag, so I have resorted to using that instead.

syleishere avatar May 15 '21 17:05 syleishere

I think if you really wanted to support it for future plugins you'd have to do something like aiomysql does, it has a feature to grab current running eventloop instead of defaulting to their own.

syleishere avatar May 15 '21 17:05 syleishere

If you face same problem, use validate_email. It works perfectly without error. link. https://pypi.org/project/validate_email/

quroom avatar Sep 23 '22 03:09 quroom

Can you guys try the 2.4.4 version and see if it works? pip3 install verify-email==2.4.4.dev0

kakshay21 avatar Oct 03 '22 20:10 kakshay21

2.4.4.dev0 it does not work neither :(

jorgeroman avatar Oct 28 '22 18:10 jorgeroman

@jorgeroman can you try this? https://github.com/kakshay21/verify_email/issues/48#issuecomment-1685262024 feel free to reopen this issue if that doesn't work out.

kakshay21 avatar Sep 22 '23 14:09 kakshay21