Python 2.7 Openerp异步进程

Python 2.7 Openerp异步进程,python-2.7,asynchronous,openerp,openerp-7,Python 2.7,Asynchronous,Openerp,Openerp 7,这与,;我有一个耗时的python方法,需要异步运行(由用户启动),这样用户可以在方法在后端运行时继续处理其他事情 我正在使用线程,但游标被关闭,我必须重新创建它,当写入DB时,我得到错误“GeneratorContextManager”对象没有属性“dbname” 我的简化代码: import threading def call_validar(self, cr, uid, ids, context=None): t = threading.Thread(t

这与,;我有一个耗时的python方法,需要异步运行(由用户启动),这样用户可以在方法在后端运行时继续处理其他事情

我正在使用线程,但游标被关闭,我必须重新创建它,当写入DB时,我得到错误“GeneratorContextManager”对象没有属性“dbname”

我的简化代码:

    import threading

    def call_validar(self, cr, uid, ids, context=None):
        t = threading.Thread(target=self.test_threading, args=(cr, uid, ids, context,))
        t.start()
        return True

    def test_threading(self, cr, uid, ids, context=None):   
        for id in ids:
            my_cr = self.pool.cursor()  # Cursor needs to be re-created            
            try:
                self.write(my_cr, uid, id, {'validation_logs': 'Just anything'})    
            except Exception, e:     # 'GeneratorContextManager' object has no attribute 'dbname'   
                _logger.info('Error e [%s] context [%s]' % (e,context))             
        return True
我错过了什么


Mayte

对于后台运行的流程,您需要做什么?脚本从REST服务器加载销售数据,并在OpenERP(sale.order、account.invoice、account、凭单、account.move、stock.move等)上进行处理,平均销售150次。目前,这个过程是通过一个调度器完成的,但现在我们需要它作为用户启动。