handling multiple threads
Kevin Stone <[email protected]> Wed, 19 Jun 2013 20:26:07 +0000
| Newsgroups | gmane.comp.python.sybase |
|---|---|
| Message-ID | <CDE78C19.15A90%[email protected]> |
--===============7563969889547309064==
Content-Language: en-US
Content-Type: multipart/alternative;
boundary="_000_CDE78C1915A90kevinstonejaxorg_"
--_000_CDE78C1915A90kevinstonejaxorg_
Content-Type: text/plain; charset="us-ascii"
content-transfer-encoding: quoted-printable
I am trying to develop a python webapp using pysybase that is pretty basic.=
I want to be able to create SQL QC reports that our users can update on dem=
and as they edit the database.
However, I am having problems getting this to work in a multi-threaded envir=
onment like cherrypy. If I execute one long query, no new connections can be=
made, in fact all other threads come to a halt until that one query returns=
. Is this something that is not supported by this driver?
Here is a sample test that I've been using:
def sy_query(query):
db =3D Sybase.connect(dbServer,dbUser,dbPass,dbName)
cur =3D db.cursor()
cur.execute(query)
t1 =3D Thread(target=3Dsy_query,args=3D("select * from blah",))
t2 =3D Thread(target=3Dsy_query,args=3D("select something from blah2",))
t1.start()
t2.start()
t1.join()
t2.join()
As soon as thread 1 calls "status =3D ct_results(self->cmd, &result);" insid=
e of cmd.c nothing happens in either the main function nor in thread 2.
Immediately after that line finishes, everything moves along.
Any suggestions? I can't have a webapp that only works for one user at a tim=
e.
-Kevin
The information in this email, including attachments, may be confidential an=
d is intended solely for the addressee(s). If you believe you received this=
email by mistake, please notify the sender by return email as soon as possi=
ble.
--_000_CDE78C1915A90kevinstonejaxorg_
Content-Type: text/html; charset="us-ascii"
Content-ID: <[email protected]>
content-transfer-encoding: quoted-printable
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii">
</head>
<body style=3D"color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, s=
ans-serif; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-bre=
ak: after-white-space; ">
<div>I am trying to develop a python webapp using pysybase that is pretty ba=
sic. I want to be able to create SQL QC reports that our users can update on=
demand as they edit the database. </div>
<div><br>
</div>
<div>However, I am having problems getting this to work in a multi-threaded=
environment like cherrypy. If I execute one long query, no new connections=
can be made, in fact all other threads come to a halt until that one query=
returns. Is this something that
is not supported by this driver?</div>
<div><br>
</div>
<div>Here is a sample test that I've been using:</div>
<div><br>
</div>
<div>
<div style=3D"margin: 0px; padding: 0px; border: 0px; vertical-align: baseli=
ne; color: rgb(34, 34, 34); font-family: Arial, Helvetica, sans-serif; font-=
size: 13px; font-style: normal; font-variant: normal; font-weight: normal; l=
etter-spacing: normal; line-height: normal; orphans: auto; text-align: start=
; text-indent: 0px; text-transform: none; white-space: normal; widows: auto;=
word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(25=
5, 255, 255);">
<div style=3D"margin: 0px; padding: 0px; border: 0px; vertical-align: baseli=
ne;">def sy_query(query):</div>
<div style=3D"margin: 0px; padding: 0px; border: 0px; vertical-align: baseli=
ne;"> db =3D Sybase.connect(dbServer,<wbr>dbUser,=
dbPass,dbName)</div>
<div style=3D"margin: 0px; padding: 0px; border: 0px; vertical-align: baseli=
ne;"> cur =3D db.cursor()</div>
<div style=3D"margin: 0px; padding: 0px; border: 0px; vertical-align: baseli=
ne;"> cur.execute(query)</div>
</div>
<div style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin=
-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; paddi=
ng-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-=
width: 0px; border-left-width: 0px; border-style: initial; border-color: ini=
tial; vertical-align: baseline; color: rgb(34, 34, 34); font-family: Arial,=
Helvetica, sans-serif; font-size: 13px; font-style: normal; font-variant: n=
ormal; font-weight: normal; letter-spacing: normal; line-height: normal; tex=
t-align: start; text-indent: 0px; text-transform: none; white-space: normal;=
word-spacing: 0px; -webkit-text-stroke-width: 0px; ">
<div style=3D"background-color: rgb(255, 255, 255); margin-top: 0px; margin-=
right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-=
right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; b=
order-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; bo=
rder-style: initial; border-color: initial; vertical-align: baseline; ">
t1 =3D Thread(target=3Dsy_query,args=3D("<wbr>select * from blah",=
))</div>
<div style=3D"background-color: rgb(255, 255, 255); margin-top: 0px; margin-=
right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-=
right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; b=
order-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; bo=
rder-style: initial; border-color: initial; vertical-align: baseline; ">
t2 =3D Thread(target=3Dsy_query,args=3D("<wbr>select something from bla=
h2",))</div>
<div style=3D"background-color: rgb(255, 255, 255); margin-top: 0px; margin-=
right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-=
right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; b=
order-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; bo=
rder-style: initial; border-color: initial; vertical-align: baseline; ">
t1.start()</div>
<div style=3D"background-color: rgb(255, 255, 255); margin-top: 0px; margin-=
right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-=
right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; b=
order-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; bo=
rder-style: initial; border-color: initial; vertical-align: baseline; ">
t2.start()</div>
<div style=3D"background-color: rgb(255, 255, 255); margin-top: 0px; margin-=
right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-=
right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; b=
order-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; bo=
rder-style: initial; border-color: initial; vertical-align: baseline; ">
t1.join()</div>
<div style=3D"background-color: rgb(255, 255, 255); margin-top: 0px; margin-=
right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-=
right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; b=
order-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; bo=
rder-style: initial; border-color: initial; vertical-align: baseline; ">
t2.join()</div>
<div style=3D"background-color: rgb(255, 255, 255); "><br>
</div>
<div style=3D"background-color: rgb(255, 255, 255); "><br>
</div>
<div>As soon as thread 1 calls "status =3D ct_results(self->cmd, &am=
p;result);" inside of cmd.c nothing happens in either the main function=
nor in thread 2.</div>
<div>Immediately after that line finishes, everything moves along.</div>
<div><br>
</div>
<div>Any suggestions? I can't have a webapp that only works for one user at=
a time.</div>
<div><br>
</div>
<div>-Kevin</div>
</div>
</div>
<p>The information in this email, including attachments, may be confidential=
and is intended solely for the addressee(s). If you believe you received th=
is email by mistake, please notify the sender by return email as soon as pos=
sible.</p>
</body>
</html>
--_000_CDE78C1915A90kevinstonejaxorg_--
--===============7563969889547309064==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
--===============7563969889547309064==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Python-sybase-misc mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/python-sybase-misc
--===============7563969889547309064==--