Source

sandbox / mp.py

import multiprocessing

def f(foo, bar=None):
	result = foo + bar if bar else foo
	return result, bar is not None

def pool_in_globals():
	return 'pool' in globals()

def process_name():
	return multiprocessing.current_process().name

pool = multiprocessing.Pool(1)

class MyClass(object):

	def do_it(self):
		args = [3,4]
		kwargs = dict()
		print 'result is', pool.apply(f, args, kwargs)
		print 'result is', pool.apply(f, [3])
		try:
			print 'result is', pool.apply(f, [3,'x'])
		except TypeError:
			print 'type error'
		print 'pool_in_globals() ->', pool.apply(pool_in_globals, [])
		print 'process name in main:', process_name()
		print 'process name in child:', pool.apply(process_name)

if __name__ == '__main__':
	o = MyClass()
	o.do_it()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.