I know this has been answered before, but it seems that executing the script directly \"python filename.py\" does not work. I have Python 2.6.2 on SuSE Linux.
Code:<
This comes from the fact that with p = Pool(1) the main process forks processes (threads vs processes) before it creates the function f. As stated in Bartosz answer the spawned processes do not have access to the new function.
def f1(x):
...
p = Pool(1) # p is spawned and is now an independent process, knows f1
def f(x): # p doesn't not share this object
...