Updating database with callback in Parallel Python
===

I'm trying to do some text processing on around 200,000 entries in a SQlite database which I'm accessing using SQLAlchemy.  I'd like to parallelize it (I'm looking at Parallel Python), but I'm not sure how exactly to do it.

I want to commit the session each time an entry is processed, so that if I need to stop the script I won't lose the work it's already done.  However, when I try to pass the session.commit() command to the callback function, it does not seem to work.
    
    from assignDB import *
    from sqlalchemy.orm import sessionmaker
    import pp, sys, fuzzy_substring
    
    def matchIng(rawIng, ingreds):
    maxScore = 0
    choice = ""
    for (ingred, parentIng) in ingreds.iteritems():
        score = len(ingred)/(fuzzy_substring(ingred,rawIng)+1)
        if score > maxScore:
            maxScore = score
            choice = ingred
            refIng = parentIng  
    return (refIng, choice, maxScore)

    def callbackFunc(match, session, inputTuple):
        print inputTuple
        match.refIng_id = inputTuple[0]
        match.refIng_name = inputTuple[1]
        match.matchScore = inputTuple[2]
        session.commit()
    
    # tuple of all parallel python servers to connect with
    ppservers = ()
    #ppservers = ("10.0.0.1",)

    if len(sys.argv) > 1:
        ncpus = int(sys.argv[1])
        # Creates jobserver with ncpus workers
        job_server = pp.Server(ncpus, ppservers=ppservers)
    else:
        # Creates jobserver with automatically detected number of workers
        job_server = pp.Server(ppservers=ppservers)

    print "Starting pp with", job_server.get_ncpus(), "workers"

    ingreds = {}
    for synonym, parentIng in session.query(IngSyn.synonym, IngSyn.parentIng): 
        ingreds[synonym] = parentIng
    
    jobs = []
    for match in session.query(Ingredient).filter(Ingredient.refIng_id == None):
        rawIng = match.ingredient
        jobs.append((match, job_server.submit(matchIng,(rawIng,ingreds),    (fuzzy_substring,),callback=callbackFunc,callbackargs=(match,session))))

The session is imported from `assignDB`.  I'm not getting any error, it's just not updating the database.

Thanks for your help.