Any insights into running a jython script as a daemon on Linux?  I realize that you cannot spawn processes, so true forking is out of the question.

Let me retrace my steps, and jump in if you see a place to make a suggestion.

1. I wrote a SimpleXMLRPCServer that runs forever. 

2. For my purposes, I want to run it as a Linux service, so I worked up an init script, but was quickly reminded that, to run as a service, the program should fork and exit.

3.  I had used the UNIX double-fork trick with Python (, but got an error when I tried with jython since you can't fork with JAVA.  (fork method is unsupported)

4.  I found Jason R. Briggs' Pseudofork (, read his comment towards the end that reads, "why didn't I use jython 'threading'? I forget"

5.  If Jason wasn't sure, I figured I'd better check out the threading option before committing to pseudofork.  Found this little snip that seemed to do the trick.  The simple example worked wonderfully.  The thread continues to live on though the script exits.

import threading, sys
class TT(threading.Thread):

    def __init__(_):

    def run(_):
        print 'running'
        while 1:

tt = TT()

But...recall that I'm running a SimpleXMLRPCServer, so my version includes this code in the run func:

    server = SimpleXMLRPCServer(("localhost", 8111))


    # Run the server's main loop

Once SimpleXMLRPCServer is added to the code, the spawned thread dies upon exit.  In short, no daemon solution for me here.

Does pseudofork look like my best option?  I have a nagging feeling that there is a simpler solution that I am overlooking.