Hi Eugene,

I'm not getting the error on a web page as such. The project is to
create a scheduling engine in python which uses Django for its
interface. The error comes out of the python programme run from DOS.
Essentially I'm using the Django web interface to maintain a list of
events:

class Ec_event(meta.Model):
    ec_event_date_time = meta.DateTimeField('date/time')
    ec_event_type = meta.CharField(maxlength=10)
    ec_event_text = meta.CharField(maxlength=60)
    ec_event_processed = meta.BooleanField()
    ec_event_completed = meta.BooleanField()
    ec_event_succeeded = meta.BooleanField()
    ec_event_cancelled = meta.BooleanField()

I run a standalone python programme (called kron) which looks for new
events in the table and spawns a thread to process them:

    new_event_list = ec_events.get_list(
        ec_event_processed__exact = False,
        ec_event_cancelled__exact = False,)
...
    for this_inst in new_event_list:
        this_inst.ec_event_processed = True
        this_inst.save()
        thread.start_new_thread(thread_test,(this_inst,))

Inside the thread I process the event's tasks and then write a status
back to the events table:

def thread_test(inst):
...
    inst.ec_event_completed = True
    db_save(inst)

Processing of the new events list takes place every 30 seconds while
the thread will process the event tasks at an arbitrary time. What
seems to happen is that the thread writing back to the database
conflicts at random intervals with the main programme changing other
event attributes and throws the 2013 error. The error can be avoided
manually by disabling the database write in the thread or by keeping a
lock variable on the database so saves never coincide.

Thanks again for your help,
Mike


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to