Discussion:
[python-win32] PID of a process created by win32com.client.Dispatch()
Bruce Webber
2007-03-06 02:01:13 UTC
Permalink
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.) Thanks.

--
Bruce Webber
***@brucewebber.us
http://brucewebber.us
Tim Roberts
2007-03-06 18:23:18 UTC
Permalink
Post by Bruce Webber
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 Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
Bruce Webber
2007-03-07 20:59:35 UTC
Permalink
Post by Tim Roberts
Post by Bruce Webber
I've written a program which automates the running of Business Objects
(a query generator and reporting tool). The command which creates the
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
***@brucewebber.us
http://brucewebber.us
Loading...