[python-win32] PID of a process created by win32com.client.Dispatch()

Bruce Webber bruce at brucewebber.us
Wed Mar 7 21:59:35 CET 2007


--Tim Roberts <timr at probo.com> wrote:

> Bruce Webber wrote:
>> I've written a program which automates the running of Business Objects
>> (a query generator and reporting tool). The command which creates the
>> process (and the corresponding Python object) is:
>>
>> boApp = win32com.client.Dispatch('BusinessObjects.Application')
>>
>> This works fine, and I have successfully run the application. However,
>> sometimes the Business Objects process hangs (perhaps because the query
>> takes too long or perhaps due to some error in my code) and I would like
>> to kill the process in Task Manager. If I am running this on my PC, it's
>> easy to identify the process to kill. If, however, I'm running this on a
>> server and there are other Business Objects processes running I cannot
>> tell which process to end.
>>
>> Upon calling Dispatch() I would like to log the PID of the process, so
>> if I have to kill, I would know which one.
>>
>> Is there a way to do this? (I have looked through the Python for Windows
>> documentation and searched on the web, but have not found any answers.)
>
> This is tricky.  Remember that win32com.client.Dispatch doesn't actually
> know whether the COM server is in-process (meaning a DLL within the
> current process) or out-of-process (meaning a separate executable).
> That's all hidden by COM.  When you talk to the boApp object, you're
> just calling into an object in your address space.  The fact that the
> object is just a proxy that calls into another process is a COM detail
> that is hidden from view.
>
> Do you have the object model for BusinessObjects?  If you are lucky,
> perhaps their object model includes a "get process ID" property.  If
> not, I'm not convinced there is a way to map a COM object to a process
> ID, and some Google searching did not come up with an answer.

Tim,

Thanks for the response.

I do have the object model for BusinessObjects but there is no property or 
method that provides the process ID. Since my company has a support 
contract with them, and since they do provide the object model as part of 
their SDK, I will contact them and ask if there is some undocumented way of 
doing it.

-- 
Bruce Webber
bruce at brucewebber.us
http://brucewebber.us


More information about the Python-win32 mailing list