[Zope] Asynchronous DTML
W. Robert Kellock
sales@creditscore.co.nz
Fri, 5 Oct 2001 14:32:23 +1200
Thanks Chris,
Anybody else able to shed some light on my problem?
If the promises of .NET are realised we should be doing a lot more calling
out to external servers like this from Zope.
----------------------------------------------------------------------------
---------------------------------
W.Robert Kellock Ph:
+64 3 326 6115
Sales Manager Fax:
+64 3 326 6115
Credit Systems Control Ltd Web:
www.creditscore.co.nz
"making decisions easy"
----------------------------------------------------------------------------
---------------------------------
----- Original Message -----
From: "Chris McDonough" <chrism@digicool.com>
To: "W. Robert Kellock" <sales@creditscore.co.nz>
Sent: Friday, 5 October 2001 14:32
Subject: Re: [Zope] Asynchronous DTML
> Hmm... not exactly a socket programming guru here.. would you mind
> sending this to the list? I wonder if there's a system call somewhere
> in here that locks a mutex. I'm not sure but someone else might know.
>
> Just for a sanity check, you might want to write an external method like:
>
> import thread, time, zLOG
>
> def test(self):
> ident = thread.get_ident()
> zLOG.LOG('test', 0, "starting in %s at %s" % (ident, time.time()))
> time.sleep(10)
> zLOG.LOG('test', 0, " ending in %s at %s" % (ident, time.time()))
>
> Then fire off a few requests to it to prove to yourself that it's not
> serializing the calls (if no time periods in the log overlap, it's
> serializing). Youc an see the log by starting Zope up like this:
>
> ./start STUPID_LOG_FILE=debug.log
>
> - C
>
> W. Robert Kellock wrote:
> > The following external method definitely blocks on my RedHat 7.1 Linux
box.
> > Any ideas?
> >
> > from socket import *
> > import time
> > import string
> >
> > def GetBureau(self,host,port,request,terminator):
> > s = socket(AF_INET,SOCK_STREAM)
> > s.connect((host,port))
> > s.setblocking(0) #non-blocking to allow us to time out
> > s.send(request)
> > start = time.time()
> > data = ''
> > buffer = ''
> > cont = 1
> > while cont:
> > cont = 0
> > try:
> > buffer = s.recv(256)
> > except:
> > pass
> > if len(buffer):
> > cont = 1
> > last = string.count(buffer,terminator)
> > if (last > 0):
> > cont = 0
> > buffer = buffer[:string.find(buffer,terminator) +
> > len(terminator)]
> > data = data + buffer
> > buffer = ''
> > else:
> > if (start + 60 > time.time()):# time out if no response
> > cont = 1
> > else:
> > if (len(data) > 0):
> > pass
> > else:
> > data = ''
> > s.close()
> > return data
> >
>
> --------------------------------------------------------------------------
--
> > ---------------------------------
> > W.Robert Kellock Ph:
> > +64 3 326 6115
> > Sales Manager Fax:
> > +64 3 326 6115
> > Credit Systems Control Ltd Web:
> > www.creditscore.co.nz
> > "making decisions easy"
>
> --------------------------------------------------------------------------
--
> > ---------------------------------
> >
> > ----- Original Message -----
> > From: "Chris McDonough" <chrism@digicool.com>
> > To: "W. Robert Kellock" <sales@creditscore.co.nz>
> > Cc: <zope@zope.org>
> > Sent: Friday, 5 October 2001 13:56
> > Subject: Re: [Zope] Asynchronous DTML
> >
> >
> >
> >>Zope is multithreaded and there are typically no locks on any resources
> >>that prevents one thread from operating independently of another, so
> >>what you want is likely available out of the box.
> >>
> >>W. Robert Kellock wrote:
> >>
> >>>Hello,
> >>>
> >>>
> >>>
> >>>Does anyone know how to prevent an external method from blocking?
> >>>
> >>>
> >>>
> >>>What I need is an external method that contacts an external server and
> >>>returns the result to be displayed in my dtml page. It's quite alright
> >>>for the person requesting the page to wait for the response. What I
> >>>don't want is for other users to be blocked while the external server
> >>>formulates it's response to that user.
> >>>
> >>>
> >>>
> >>> From the archives it seems I need to piggyback onto Zopes asyncore /
> >>>asynchat to achieve this, but I'm not sure how.
> >>>
> >>>
> >>>
> >>>Thanks.
> >>>
> >>>
>
>>--------------------------------------------------------------------------
> >>
> > -----------------------------------
> >
> >>>W.Robert Kellock
> >>>Ph: +64 3 326 6115
> >>>Sales Manager
> >>>Fax: +64 3 326 6115
> >>>Credit Systems Control Ltd Web:
> >>>www.creditscore.co.nz <http://www.creditscore.co.nz>
> >>> "making decisions easy"
> >>>
>
>>--------------------------------------------------------------------------
> >>
> > -----------------------------------
> >
> >>
> >>--
> >>Chris McDonough Zope Corporation
> >>http://www.zope.org http://www.zope.com
> >>"Killing hundreds of birds with thousands of stones"
> >>
> >>
> >
>
>
> --
> Chris McDonough Zope Corporation
> http://www.zope.org http://www.zope.com
> "Killing hundreds of birds with thousands of stones"
>