Hi i am coding a python script and build several child processes that fetch and execute tasks in the database.

The duties are placed around the database with a php website running on a single machine.

What is the good (need this to become fast) method to choose increase individuals tasks as "happening" to prevent to become selected by multiple occasions through the python scripts

edit: database is mysql

Thanks ahead of time

Without learning more about your architecture, We highly recommend the following method.

1) Lock Process table
2) Select ... from Process table where State="New"
3) processlist = [list of process id''s from step 2]
4) Update Process table set State="In progress" where ProcessId in [processlist]
5) Unlock Process table.

A method to quicken things would be to place the process right into a saved procedure, and return the chosen row from that procedure. This way, just one visit to the db server.

Make use of an InnoDB table Tasks, then:

select TaskId, ... from Tasks where State="New" limit 1;
update Tasks set State="In Progress" where TaskId=<from above> and State="New";

when the update works, you are able to focus on the job. Otherwise, repeat the process.

You will want a catalog on TaskId and Condition.