Welcome to my blog. This blog was created mainly to help track my progress in Google's Summer of Code 2007, on which I've started implementing the Bug Triage and Forward Tool for the Debian Project. Currently I use it to write what I'm doing on free software projects or whatever is in my mind when I get some time/spirit to write.
Saturday, 30 June 2007
Python, os.fork() and GSoC
This one was a bit tricker to find, so I'm going to post it here: if you use os.fork() on Python, you will want to use os._exit() on the child process, or it will clean stuff it shouldn't and you will have segfaults with doubled memory free.
That said, python's webbrowser module is quite useful; check it if you ever has to open a browser from a Python script/program. The only downside I see on it is exactly that it doesn't takes care of the forking stuff for you. I'm using it on bug-triage to show a bug report on the user browser.
Talking about GSoC, during the last week the Debian BTS was updated, breaking, between other things, btsutils' 0.1 version. The current development version of btsutils, which uses BeautifulSoup to parse the HTML stuff more realiable, wasn't affected by the update.
That's all for now, time to code.
Can you provide some code to demonstrate the fork/exit problem?
ReplyDeleteWhen you use os.fork(), you get two processes with their own memory areas. The child *cannot* make modifications to the parent's memory. Unless you used shared memory or some other form of interprocess communication. (I imagine file locks and sockets may cause problems if you're not careful.)