<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>Twisted, Threading, Extension Modules and the GIL</TITLE>
<META content="MSHTML 6.00.2800.1400" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=355313922-03032005>I just
realised after re-reading my post that the call to deferToThread should have
been:</SPAN></FONT></DIV>
<DIV><FONT><SPAN class=355313922-03032005><FONT face=Arial color=#0000ff
size=2></FONT></SPAN></FONT> </DIV>
<DIV><FONT><SPAN class=355313922-03032005><FONT face=Arial color=#0000ff
size=2>d = threads.deferToThread(self.builder.newbuild<SPAN
class=355313922-03032005>,
</SPAN>buildJob)<BR>d.addCallback(self.builderFinished)</FONT></DIV>
<DIV>
<P><SPAN class=355313922-03032005><FONT face=Arial color=#0000ff size=2>How
silly of me, i'll test it now and see if there are still
problems!</FONT></SPAN></P></SPAN></FONT></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B>
twisted-python-bounces@twistedmatrix.com
[mailto:twisted-python-bounces@twistedmatrix.com]<B>On Behalf Of </B>Grant
McDonald<BR><B>Sent:</B> 04 March 2005 09:20<BR><B>To:</B>
twisted-python@twistedmatrix.com<BR><B>Subject:</B> [Twisted-Python] Twisted,
Threading, Extension Modules and the GIL<BR><BR></FONT></DIV>
<P><FONT size=2>Hi everyone,</FONT> </P>
<P><FONT size=2>I have a threading question regarding Twisted and the
explanation is a bit long-winded but please bear with me.</FONT> </P>
<P><FONT size=2>The scenario:</FONT> </P>
<P><FONT size=2>I have created an automated build system in Python for
PowerBuilder (awful language) that allows a scheduler to assign build jobs to
dispatcher programs across a network. These dispatchers have a GUI
component coded in wxPython. The initial implementation involved also
creating a separate builder program that was spawned by the dispatchers when a
build job was received. The builder code called an extension module to
interface with the low-level PowerBuilder compiler library. This was
done due to the fact the calls to rebuild the application and deploy it are
exceptionally CPU-intensive and don't return for many minutes (approx. 30 or
so for a large application) and all attempts to include this in the dispatcher
resulted in the user interface freezing.</FONT></P>
<P><FONT size=2>Recently I came across twisted documentation with regards to
programming using twisted threads. As an experiment on this concept I
amalgamated the dispatcher and </FONT></P>
<P><FONT size=2>builder programs and called the builder code using the
following:</FONT> </P>
<P><FONT size=2>d =
threads.deferToThread(self.builder.newbuild(buildJob))</FONT> <BR><FONT
size=2>d.addCallback(self.builderFinished)</FONT> </P>
<P><FONT size=2>It should be noted that the extension module (a pyrex
extension I have created myself) implements the releasing and re-acquiring of
the Global Interpreter Lock for all blocking calls. From my
understanding this should work but the user interface freezes. Can
someone please point me in the direction of a solution?</FONT></P>
<P><FONT size=2>Thanks,</FONT> </P>
<P><FONT size=2>Grant McDonald</FONT> </P><!--[object_id=#infocomp.com#]-->
<P><FONT face=Arial color=#808080 size=1>Important notice: This message is
intended for the individual(s) and entity(s) addressed. The information
contained in this transmission and any attached, may be confidential and may
also be the subject of legal privilege, public interest immunity or legal
professional privilege. Any review, retransmission, dissemination or other use
of, taking of any action in reliance upon this information by person or
entities other than the recipient is prohibited and requires authorization
from the sender. If you are not the addressee indicated in this message (or
responsible for delivery of the message to such person) you may not copy or
deliver this message to anyone. In such cases you should destroy this message
and kindly notify the sender by reply email. </FONT></P>
<P><FONT face=Arial color=#808080 size=1>WARNING: Although Infocomp has taken
reasonable precautions so that no viruses are present in this e-mail, the
company cannot accept responsibility for any loss or damage arising from the
use of e-mail attachments.</FONT></P></BLOCKQUOTE></BODY></HTML>