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

 

你可能感兴趣的:(Odoo在eclipse下的debug)