<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Carol,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>As a quick fix, we have created a stand
alone program that does the database access.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>So from the python external method (zope) that
retrieves data, instead of making the connections to the DB directly it now
calls os.popen(&#8220;python getdata.py&#8221;).<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>This forces the launch of a separate python
interpreter for the duration of the query.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Unfortunately, we will suffer the overhead
of doing this for each DB call, but that is far better than denying service to
all other sessions.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>We are already in the process of moving to
MySQL for our databases, and the MySQL adapter does not appear to exhibit this
behavior.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Jon Emmons<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'> Carol Ludwig
[mailto:csl@med.unc.edu] <br>
<b><span style='font-weight:bold'>Sent:</span></b> Wednesday, June 04, 2008
10:58 AM<br>
<b><span style='font-weight:bold'>To:</span></b> Jon Emmons<br>
<b><span style='font-weight:bold'>Cc:</span></b> 'Dieter Maurer'; zope@zope.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> Re: RE: [Zope]
Multithreading sessions</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>We are using Plone and Zope against a legacy Ingres database, and I
found a similar problem<br>
using the adapter provided.&nbsp; I found that the C library modules (open
source) actually contained<br>
calls to make the adapter work as we wanted, much like our other web interfaces
which maintain<br>
the db and user permissions info as a &quot;connection&quot;, but close the
actual query after each.&nbsp; I had<br>
to modify the Python Zope product to set &quot;autocommit&quot; and call the
desired close in order to get <br>
the behaviour we were looking for -- keeping the connection, but releasing each
session so that<br>
&nbsp;the DB backend does not register an active session between actual
queries.<br>
<br>
That's open source.&nbsp; Code terminology for &quot;re-write it&quot;.<br>
<br>
----- Original Message -----<br>
From: Jon Emmons &lt;jon.emmons@earthwavetech.com&gt;<br>
Date: Wednesday, June 4, 2008 8:50<br>
Subject: RE: [Zope] Multithreading sessions<br>
To: 'Dieter Maurer' &lt;dieter@handshake.de&gt;<br>
Cc: zope@zope.org<br>
<br>
&gt; Dieter,<br>
&gt; <br>
&gt; Thanks for this input.&nbsp; Your comments here turned out to be <br>
&gt; dead on.&nbsp; The<br>
&gt; problem is the GIL.<br>
&gt; <br>
&gt; We are currently running Sybase databases using the python <br>
&gt; Sybase-0.37<br>
&gt; module for data access.<br>
&gt; <br>
&gt; This module will set the GIL.&nbsp; So if the query takes any <br>
&gt; time at all, every<br>
&gt; other session will freeze.&nbsp; It does release it when the <br>
&gt; connection is<br>
&gt; closed, but if the query takes awhile it effectively denies <br>
&gt; service to every<br>
&gt; other session.<br>
&gt; <br>
&gt; I am just learning about this, but my initial inquiries suggest <br>
&gt; that the<br>
&gt; only way to achieve true concurrency using a language like <br>
&gt; python is to<br>
&gt; launch multiple interpreters.<br>
&gt; <br>
&gt; I don't yet have the solution to my problem, but at least now I <br>
&gt; know what<br>
&gt; the problem is, and that is half the battle.<br>
&gt; <br>
&gt; Thanks again, and thanks to everyone's input, it has helped immensely.<br>
&gt; <br>
&gt; Jon Emmons<br>
&gt; <br>
&gt; -----Original Message-----<br>
&gt; From: Dieter Maurer [mailto:dieter@handshake.de] <br>
&gt; Sent: Wednesday, May 28, 2008 2:27 PM<br>
&gt; To: Jon Emmons<br>
&gt; Cc: zope@zope.org<br>
&gt; Subject: Re: [Zope] Multithreading sessions<br>
&gt; <br>
&gt; Jon Emmons wrote at 2008-5-23 08:58 -0400:<br>
&gt; &gt; ...<br>
&gt; &gt;I am running zope 2.9.4 and have observed that it will not <br>
&gt; simultaneously&gt;serve pages to my users.<br>
&gt; <br>
&gt; Usually, it does.<br>
&gt; <br>
&gt; I have seen database adapter packages (an old &quot;psycopg&quot; version,
<br>
&gt; to be<br>
&gt; precise) that forgot to release the GIL for some operations.<br>
&gt; Then Zope freezes while these operations are executed.<br>
&gt; <br>
&gt; <br>
&gt; A surprising report of a similar kind was: while Zope's embedded<br>
&gt; profiler is in use, Zope effectively runs in single thread mode (such<br>
&gt; that other threads do not distort the timing results).<br>
&gt; Probably not your problem ... but who knows.<br>
&gt; <br>
&gt; <br>
&gt; Further potential reasons (for almost surely not responsible for your<br>
&gt; current problem:<br>
&gt; <br>
&gt; &nbsp; Expensive operations implemented in &quot;C&quot; (such as <br>
&gt; operations on huge<br>
&gt; &nbsp; strings)<br>
&gt; <br>
&gt; &nbsp; Creating excessive amounts of objects (causing lots<br>
&gt; &nbsp; of generation 2 garbage collections which hold the GIL)<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; -- <br>
&gt; Dieter<br>
&gt; <br>
&gt; _______________________________________________<br>
&gt; Zope maillist&nbsp; -&nbsp; Zope@zope.org<br>
&gt; http://mail.zope.org/mailman/listinfo/zope<br>
&gt; **&nbsp;&nbsp; No cross posts or HTML encoding!&nbsp; **<br>
&gt; (Related lists - <br>
&gt; &nbsp;http://mail.zope.org/mailman/listinfo/zope-announce<br>
&gt; &nbsp;http://mail.zope.org/mailman/listinfo/zope-dev )<br>
&gt; <o:p></o:p></span></font></p>

</div>

</body>

</html>