odoo 使用协程,异步,gevent,打补丁

talkincode 2020-01-11

打补丁得时候需要在方法中实现,如果直接在外部调用猴子补丁,在odoo服务启动时,就会出现锁异常,会出现死锁,

错误的示范:

from odoo import api, fields, models
from dateutil.relativedelta import relativedelta

from ..controllers.cls_get_trans_info import SpiderTrans

from odoo import exceptions
import gevent
import logging
from gevent import monkey
monkey.patch_all() # 这是一个错误的示例

class ClassName(models.Model):
    _name = 'model.name'
    ...

正确的示范:

from odoo import api, fields, models
from dateutil.relativedelta import relativedelta

from ..controllers.cls_get_trans_info import SpiderTrans

from odoo import exceptions
import gevent
import logging
from gevent import monkey
monkey.patch_all() # 这是一个错误的示例

class ClassName(models.Model):
    _name = 'model.name

    field_name= fields.Char()

    def func(self):
        monkey.patch_all() #猴子补丁需要在该位置调用

相关推荐

CandyGL / 0评论 2016-03-02