[Zope-dev] Problem with starting thread in the initialization of a product ( Linux)

Lily Li lli@kaval.com
Wed, 22 Aug 2001 17:16:26 -0400


Thanks, Steve, it worked! I ran the zope as myself with port 8080. But in
the real case, we'll run it as root with port 80. So I'll try to hack z2.py
and see if I'm of good luck. Thanks again.

Lily Li

> -----Original Message-----
> From: Steve Alexander [mailto:steve@cat-box.net]
> Sent: Wednesday, August 22, 2001 4:20 PM
> To: Lily Li
> Cc: 'zope-dev@zope.org'
> Subject: Re: [Zope-dev] Problem with starting thread in the
> initialization of a product ( Linux)
> 
> 
> Lily Li wrote:
> 
> > Hi friends,
> > 
> > I've encountered a serious problem when trying to port my 
> product from win32
> > system to Linux. 
> > 
> > As we need several threads running as long as zope is up 
> running, we started
> > the thread (tried both daemon one and non-daemon one) in 
> the initialization
> > of the product like (in __init__.py):
> >   
> > 	import threading
> > 
> > 	def initialize(context):
> >                  .........
> >                  .........
> >                   t = threading.Thread()
> >                   t.setDaemon(1)
> >                   t.start()
> > 
> > Then zope will stop responding to any HTTP request. If the 
> thread is not
> > started, the zope will run correctly. Does anyone has the 
> similar experience
> > with it? It seems that the problem is caused by starting thread when
> > initializing. I did threading thing before but started by 
> HTTP request and
> > it worked fine. Besides, this code works fine on win32 systems. 
> > 
> > If anyone could give me any help as soon as possible, it's highly
> > appreciated. 
> 
> 
> Let me guess:
> 
> You've installed Zope as root.
> 
> The problem is that Zope changes uid and gid after initializing the 
> products. There's a bug/misfeature with Linux in that when a process 
> changes uid/gid, any existing threads do not change with it.
> 
> If you look up the list archives for problems with Xron, you'll see 
> reports of similar problems.
> 
> The solutions are to do one of the following:
> 
> * If you don't need Zope to access port 80, or any privilaged 
> port, run 
> Zope as a non-root user.
> 
> * Modify Zope to change uid/gid before initializing products.
> 
> * Modify Zope to notify products with a call-back after it 
> has changed 
> uid/gid, so that products can do things like launch threads.
> 
> * Modify Linux to fix the problem.
> 
> --
> Steve Alexander
> Software Engineer
> Cat-Box limited
> 
> 
> 
> 
> 
>