468,249 Members | 1,499 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

Python, COM Servers, and Multi-Threading

I have been considering using Python and the Reportlab library for
generating PDF reports for the back-end of a web based application. The
application runs most of its background tasks on a dedicated server that is
Windows based (Win2K or Win2k3). The program that launches the tasks
requires a COM-based interface, so I wrote a Python COM server using Mark
Hammond's PythonCom libraries and import and run the reporlab modules from
there.

I had been reading up on Python and it's handling of the multiple threads,
specifically the Global Interpreter Lock (GIL). I got to wondering if a
multi-processor machine machine would be able to take advantage of its
extra processing power using this setup. I am guessing that the GIL is
global with respect to each instance of a running Python interpreter, so if
say 4 interpreters were running, a 4 processor machine would be able to
take advantage of this. However, I am not quite sure how launching my
reports via COM behaves-- if I launched 4 reports this way, would that be
like launching 4 seperate instances of the Python interpreter, or would it
be just a single instance, and therefore run into the limitations of the
GIL? If so, can anybody offer suggestions as to a design that would be
better able to take advantage of a multi-processor machine?

Thanks,
Carl Waldbieser

Oct 10 '05 #1
1 1859
Carl Waldbieser wrote:
I have been considering using Python and the Reportlab library for
generating PDF reports for the back-end of a web based application. The
application runs most of its background tasks on a dedicated server that is
Windows based (Win2K or Win2k3). The program that launches the tasks
requires a COM-based interface, so I wrote a Python COM server using Mark
Hammond's PythonCom libraries and import and run the reporlab modules from
there.
Have you selected a specific threading model for your COM server? This
will affect how hardware resource are allocated as well as how sharing
takes place between different uses.
I had been reading up on Python and it's handling of the multiple threads,
specifically the Global Interpreter Lock (GIL). I got to wondering if a
multi-processor machine machine would be able to take advantage of its
extra processing power using this setup. I am guessing that the GIL is
global with respect to each instance of a running Python interpreter, so if
say 4 interpreters were running, a 4 processor machine would be able to
take advantage of this. However, I am not quite sure how launching my
reports via COM behaves-- if I launched 4 reports this way, would that be
like launching 4 seperate instances of the Python interpreter, or would it
be just a single instance, and therefore run into the limitations of the
GIL? If so, can anybody offer suggestions as to a design that would be
better able to take advantage of a multi-processor machine?

I am certainly no expert on COM threading models, but I would suspect
that if you specify you want your COM server to be in-process then you
would get a per-process interpreter.

You also need to be aware that if you trigger this stuff with IIS then
the web server itself performs thread pooling and (I believe) allocates
only one process per "application", so this may defeat your desire to
use all four processors concurrently.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Oct 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

220 posts views Thread by Brandon J. Van Every | last post: by
6 posts views Thread by Thomas Womack | last post: by
1 post views Thread by Chung Jiho | last post: by
reply views Thread by Emile van Sebille | last post: by
2 posts views Thread by Silvana Di Martino | last post: by
reply views Thread by Phillip J. Eby | last post: by
4 posts views Thread by Socheat Sou | last post: by
29 posts views Thread by Frank Millman | last post: by
31 posts views Thread by stéphane bard | last post: by
113 posts views Thread by John Nagle | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.