Odoo在eclipse下的debug

eclipse下启动Debug会报如下错误

2015-10-25 18:25:56,490 2224 INFO ? openerp.service.server: Evented Service (longpolling) running on 0.0.0.0:8072

Traceback (most recent call last):

  File "E:\GreenOdoo-8.0-win32\runtime\python\lib\gevent\greenlet.py", line 327, in run

    result = self._run(*self.args, **self.kwargs)

  File "E:\GreenOdoo-8.0-win32\source\openerp\service\server.py", line 386, in watch_parent

    ppid = os.getppid()

AttributeError: 'module' object has no attribute 'getppid'

<Greenlet at 0x4ed7e40: <bound method GeventServer.watch_parent of <openerp.service.server.GeventServer object at 0x037EDA90>>> failed with AttributeError

openerp/__init__.py 里面找到下面这几行,按照以下代码修改应该就可以了。

 

"" OpenERP core library."""

 

#----------------------------------------------------------

# Running mode flags (gevent, prefork)

#----------------------------------------------------------

# Is the server running with gevent.

import sys

evented = False

# if sys.modules.get("gevent") is not None:

#     evented = True

 

注释掉

 if sys.modules.get("gevent") is not None:

     evented = True

就能debug了,网上还有一个说法是

 

 

getppid 是 linux 的函数,win 平台的 python 没有 要自己造一个补丁,据说python3.2就有这个getppid了

_

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).

 

[python] view plain copy

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添加以上代码即可     

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值