Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6361411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:46:27+00:00 2026-05-24T23:46:27+00:00

am trying to do a transactional tasks whereby the task will rollback the database

  • 0

am trying to do a transactional tasks whereby the task will rollback the database updates if it fails to send the email.

Below is my code, any one can advice what am doing wrong here?

from celery.task import task
from django.core.mail import send_mail, send_mass_mail
from django.db import transaction


@task(name='communicator.process_emails')
@transaction.commit_manually
def process_emails():
    from models import Comm_Queue
    try:
        message = []
        for i in Comm_Queue.objects.filter(status='P').order_by('sender_email'):
            message.append((i.subject, i.content, i.sender_email, [i.recipient_email]))
            Comm_Queue.objects.filter(id=i.id).update(status='S')
        if send_mass_mail(message):
            transaction.commit()
    except Exception, e:
        print 'rolled back (exception): %s' % e.__str__()
        transaction.rollback()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:46:27+00:00Added an answer on May 24, 2026 at 11:46 pm

    Since you’re using MySQL, the first thing you need to check is whether the database engine you’re using supports transactions in the first place and whether transactions have been enabled in MySQL configuration.

    See this link for more information on MySQL/Django transaction issues: https://docs.djangoproject.com/en/dev/ref/databases/#storage-engines

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use JPA's Context Injection. Currently my code fails to have the
I'm trying to create an ANT task that takes some database properties and executes
I'm trying to read the transactional deal letter queue in MSMQ using C#.NET and
I'm trying to create a service reading the dead-letter from the transactional system dead
I'm trying to understand REST. Under REST a GET must not trigger something transactional
I'm trying to design a bulk data import task using Django's ORM ontop of
I'm trying to debug some legacy Integration Services code, and really want some confirmation
I am trying to read database scripts in a Jar file so that I
I am trying to replicate a database from SQL server 2000 to 2005 they
I'm developing an app for GAE and trying to use Task Queues. At present,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.