-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
♻️ Send account creation email asynchronously via BackgroundTasks #1505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
♻️ Send account creation email asynchronously via BackgroundTasks #1505
Conversation
saleemasekrea000
commented
May 22, 2025
@alejsdev
Hi, is there any kind of feedback?
It's been a long time...
@YuriiMotov
YuriiMotov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saleemasekrea000, hello!
Thanks for the interest in project!
The problem here is that BackgroundTasks can fail silently and in this case user will not receive the email, and admin will not notice it.
With Celery (or other similar tools) we would have retry mechanism to ensure that email has been sent.
Having this I'm not sure it's good idea to move this to BG tasks
jishnu70
commented
Oct 25, 2025
Hi @YuriiMotov ,
This is my first-ever open-source contribution. I’d like to propose making background task support optional:
- Introduce a boolean
USE_CELERYinconfig.py. - If
USE_CELERY=True, the developer can start Celery + RabbitMQ via a Docker Compose profile, for example:
docker-compose --profile celery up - If
USE_CELERY=False, only the backend runs:
docker-compose up
is this approach acceptable?
Making it a background task improves responsiveness and user experience.
For future
If you need to perform heavy background computation and you don't necessarily need it to be run by the same process (for example, you don't need to share memory, variables, etc), you might benefit from using other bigger tools like Celery
According to the FastAPI docs :
https://fastapi.tiangolo.com/tutorial/background-tasks/?h=#technical-details