'module' object has no attribute 'getppid' odoo openerp debug报错

Greenodoo8 pycharm debug 调试。magento连接器


 'module' object has no attribute 'getppid'

pydev调试代码,报'module' object has no attribute 'getppid' AttributeError: 'module' object has no attribute 'getppid'想用pydev调试代码,就报这个错...

shine-it.net/ind...php...  - 百度快照 - 评价





===================================

 原因是windows环境中没有getppid属性 


--------------------------------------------------------------

 In /opernerp/__init__.py are these lines at start.

'''
if sys.modules.get("gevent") is not None:
    evented = True
'''

Comment these lines and will work 

====================================================


@373550379 感谢指导。。

参考  http://pydev.blogspot.com/2013/01/python-get-parent-process-id-pid-in.html 




 中校】西安-张
getppid 是 linux 的函数,win 平台的 python 没有
【中校】西安- 2015-06-25 17:06:39

要自己造一个

【中校】绍兴-花中笑 2015-06-25 17:07:11

自己乱写一个吗?


 受教
【中校】西安- 2015-06-25 17:08:27

当然不能乱写了,参考  http://pydev.blogspot.com/2013/01/python-get-parent-process-id-pid-in.html 

_
Python: get parent process id (pid) in windows
Below is code to monkey-patch the os module to provide a getppid() function to get the parent process id in windows using ctypes (note that on Python 3.2, os.getppid() already works and is available on windows, but if you're on an older version, this can be used as a workaround).

import os
if not hasattr(os, 'getppid'):
    import ctypes

    TH32CS_SNAPPROCESS = 0x02L
    CreateToolhelp32Snapshot = ctypes.windll.kernel32.CreateToolhelp32Snapshot
    GetCurrentProcessId = ctypes.windll.kernel32.GetCurrentProcessId

    MAX_PATH = 260

    _kernel32dll = ctypes.windll.Kernel32
    CloseHandle = _kernel32dll.CloseHandle

    class PROCESSENTRY32(ctypes.Structure):
        _fields_ = [
            ("dwSize", ctypes.c_ulong),
            ("cntUsage", ctypes.c_ulong),
            ("th32ProcessID", ctypes.c_ulong),
            ("th32DefaultHeapID", ctypes.c_int),
            ("th32ModuleID", ctypes.c_ulong),
            ("cntThreads", ctypes.c_ulong),
            ("th32ParentProcessID", ctypes.c_ulong),
            ("pcPriClassBase", ctypes.c_long),
            ("dwFlags", ctypes.c_ulong),

            ("szExeFile", ctypes.c_wchar * MAX_PATH)
        ]

    Process32First = _kernel32dll.Process32FirstW
    Process32Next = _kernel32dll.Process32NextW

    def getppid():
        '''
        :return: The pid of the parent of this process.
        '''
        pe = PROCESSENTRY32()
        pe.dwSize = ctypes.sizeof(PROCESSENTRY32)
        mypid = GetCurrentProcessId()
        snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)

        result = 0
        try:
            have_record = Process32First(snapshot, ctypes.byref(pe))

            while have_record:
                if mypid == pe.th32ProcessID:
                    result = pe.th32ParentProcessID
                    break

                have_record = Process32Next(snapshot, ctypes.byref(pe))

        finally:
            CloseHandle(snapshot)

        return result

    os.getppid = getppid



openerp\service\server.py添加以上代码即可

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
评论 1
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值