Restructure your code so that the f()
function is defined before you create instance of Pool. Otherwise the worker cannot see your function.
#!/usr/bin/python
# -*- coding: utf-8 -*-
from multiprocessing import Pool
def f(x):
return x*x
p = Pool(1)
p.map(f, [1, 2, 3])
More Related Contents:
- Multiprocessing vs Threading Python [duplicate]
- multiprocessing: How do I share a dict among multiple processes?
- multiprocessing global variable updates not returned to parent
- How should I log while using multiprocessing in Python?
- multiprocessing: sharing a large read-only object between processes?
- Python sharing a lock between processes
- Python multiprocessing safely writing to a file
- How to use multiprocessing queue in Python?
- where to put freeze_support() in a Python script?
- Multiprocessing a for loop?
- Using Python’s Multiprocessing module to execute simultaneous and separate SEAWAT/MODFLOW model runs
- Poor scaling of multiprocessing Pool.map() on a list of large objects: How to achieve better parallel scaling in python?
- multiprocessing.pool.MaybeEncodingError: ‘TypeError(“cannot serialize ‘_io.BufferedReader’ object”,)’
- High Memory Usage Using Python Multiprocessing
- “chunksize” parameter in multiprocessing.Pool.map
- Connection problems with SQLAlchemy and multiple processes
- OSError 38 [Errno 38] with multiprocessing
- Can multiprocessing Process class be run from IDLE
- Python multiprocess profiling
- What’s the difference between ThreadPool vs Pool in the multiprocessing module?
- how to to terminate process using python’s multiprocessing
- Using python multiprocessing Pool in the terminal and in code modules for Django or Flask
- Using 100% of all cores with the multiprocessing module
- Mix Python Twisted with multiprocessing?
- Can I get a return value from multiprocessing.Process?
- How to utilize all cores with python multiprocessing
- Tensorflow and Multiprocessing: Passing Sessions
- How can I share a class between processes?
- Multiprocessing useless with urllib2?
- Python multiprocessing linux windows difference