Project

General

Profile

« Previous | Next » 

Revision 1874

db_xml.py: put(): Moved pool.apply_async() from put_child() to put_(), and don't use lambdas because they can't be pickled

View differences:

lib/db_xml.py
62 62
    def pkey(table): return sql.pkey(db, table, True)
63 63
    
64 64
    def put_(node, parent_id=None):
65
        return put(db, node, row_ct_ref, on_error, pool, store_ids, parent_id)
65
        args = (db, node, row_ct_ref, on_error, pool, store_ids, parent_id)
66
        if parent_id != None and pool != None: pool.apply_async(put, args)
67
        else: return put(*args)
66 68
    
67 69
    def on_error_(e):
68 70
        exc.add_msg(e, 'node:\n'+str(node))
......
109 111
                else: raise
110 112
    except sql.DatabaseErrors, e: on_error_(e); return None
111 113
    
112
    def put_child(node, parent_id):
113
        call = lambda: put_(node, parent_id)
114
        if pool != None: pool.apply_async(call)
115
        else: call()
116
    
117 114
    # Insert children with fkeys to parent
118
    for child in children: put_child(child, id_)
115
    for child in children: put_(child, id_)
119 116
    
120 117
    return id_

Also available in: Unified diff