[Zope] Auto restart (at Zope's own initiative !!!)

Keith J. Farmer kfarmer@thuban.org
Mon, 28 Jan 2002 15:30:14 -0800


For what it's worth, something I noticed under (the Win32 version of)
Python 2.1.x is that, in a threaded environment, Python will crash if it
an attempt to load some extensions (my case was a c-extension that
accessed a database).

I suspect that's why Chris is asking those questions.

In particular, I noticed that while this will crash:

# AstroMathTest.py
#
# Tests AstroMath against Python threads

import threading
import AstroMath
import random

BODIES =3D [2,3,4,6,7,8,9,10]
START_JD =3D 2448976
N =3D 1000

class AstroMathTest(threading.Thread):
    def run(self):
        body =3D random.choice(BODIES)
        end_jd =3D random.randrange(START_JD + 1, START_JD + 100)
        results =3D AstroMath.makeQVsop(START_JD, end_jd, N, body)
        print "Period: %s - %s\nBody: %s\nN: %s" % (START_JD, end_jd,
body, N)
        print "Results: %s" % str(results)

if __name__ =3D=3D '__main__':
    threads =3D []
    for i in range(3):
        thread =3D AstroMathTest()
        thread.start()
        threads.append(thread)
    # wait for completion
    for thread in threads:
        thread.join()
    print "All threads completed"


... whereas this will run successfully:

# AstroMathTest-2.py
#
# Tests AstroMath against Python threads

import threading
import random

BODIES =3D [2,3,4,6,7,8,9,10]
START_JD =3D 2448976
N =3D 1000

class AstroMathTest(threading.Thread):
    def run(self):
        import AstroMath
        body =3D random.choice(BODIES)
        end_jd =3D random.randrange(START_JD + 1, START_JD + 100)
        results =3D AstroMath.makeQVsop(START_JD, end_jd, N, body)
        print "Period: %s - %s\nBody: %s\nN: %s" % (START_JD, end_jd,
body, N)
        print "Results: %s" % str(results)

if __name__ =3D=3D '__main__':
    threads =3D []
    for i in range(3):
        thread =3D AstroMathTest()
        thread.start()
        threads.append(thread)
    # wait for completion
    for thread in threads:
        thread.join()
    print "All threads completed"


.. just by changing where the import statement lies.

Is there some way to translate this to how we should write with Zope
external methods in mind?

----------
Keith J. Farmer
kfarmer@thuban.org
http://www.thuban.org


-----Original Message-----
From: Chris McDonough [mailto:chrism@zope.com]
Sent: Monday, January 28, 2002 15:19

exercising no codepaths that might kick off a relational database=20
request or exercise another C extenision?