[Zope] Threads in ExternalMethods

Juan Carlos Coruņa jcoruna@ibdosnorte.com
Fri, 11 May 2001 17:06:31 +0200


Yes, I have fired off a new thread and passed it in the contructor the self
variable. It seems to be problems in referencing other zope methods from
within the new started thread.

Here is my example, I call the listaArticulos method:

def listaArticulos(self, REQUEST, RESPONSE):

    generando = GenerarEnviarListaPrecios(self, REQUEST, RESPONSE)
    generando.start()
    return 1

def longProcess(context):
    # long process for example:
    return context.context.myZopeSqlMethod()

class GenerarEnviarListaPrecios(Thread):
    def __init__(self, context, REQUEST, RESPONSE):
        Thread.__init__(self)
        self.context = context
        self.REQUEST = REQUEST
        self.RESPONSE = RESPONSE

    def run(self):
        result = longProcess(self.context)
        .... mail result ....
        return



> -----Mensaje original-----
> De: Chris McDonough [mailto:chrism@digicool.com]
> Enviado el: viernes, 11 de mayo de 2001 16:53
> Para: Juan Carlos Coruņa; zope@zope.org
> Asunto: Re: [Zope] Threads in ExternalMethods
>
>
> Hi Juan... you need to either fire off a new process or a new thread.  =
See
> the Python documentation for more info about how to do this (the
> threading,
> thread, and os modules).
>
> ----- Original Message -----
> From: "Juan Carlos Coruņa" <jcoruna@ibdosnorte.com>
> To: <zope@zope.org>
> Sent: Friday, May 11, 2001 10:40 AM
> Subject: [Zope] Threads in ExternalMethods
>
>
> > Hi all,
> >
> > I am now trying to create an ExternalMethod that executes a long proc=
ess
> > (about 30 seconds) in a new thread and then this thread sends the res=
ult
> per
> > e-mail. The ExternalMethod must return inmediatly. I need this
> behavior in
> > order to not block the user while browsing.
> >
> > Are there anybody that can help me?
> >
> >
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )
> >