<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2657.73">
<TITLE>Twisted, Threading, Extension Modules and the GIL</TITLE>
</HEAD>
<BODY>

<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.&nbsp; These dispatchers have a GUI component coded in wxPython.&nbsp; The initial implementation involved also creating a separate builder program that was spawned by the dispatchers when a build job was received.&nbsp; The builder code called an extension module to interface with the low-level PowerBuilder compiler library.&nbsp; 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.&nbsp; 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.&nbsp; From my understanding this should work but the user interface freezes.&nbsp; 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>

</BODY>
<!--[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&nbsp;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></HTML>