TurboGears and FORK

TurboGears and FORK

Whilst working on Enomalism, I ran into an interesting issue; when I provision a new Domain, I need to untar a giant drive image. Turns out that it is a good idea to make sure it runs in the background, since TurboGears will block while writing the file.

I decided to use Fork in order to avoid the Global Interpreter Lock problems that pop up with it (and as a side note, a small RAM sacrifice avoids the problem here). The next problem was that I ended up with unterminable background processes since TurboGears tries to intercept the sys.exit() calls to reload the app. That is only a problem during development, and easily solved with kill "yourProcessHere" calls.

The outcome? It is trivial to call Fork from TurboGears, and I had no problem running background LDAP and tarfile calls, so you should be OK too! I have not yet tested to see how it deals with the JSON callbacks, but I suspect that they will generally timeout WAY BEFORE the provisioning is done.

Home Home
http://www.reaysmoving.com/