import multiprocessing
import uuid
def test():
print str(uuid.uuid4())
p = multiprocessing.Pool(processes=4)
for x in xrange(0, 4):
p.apply_async(test)
In MacOS:
Gavin-M-Roys-Office-iMac:kvpbench gmr$ python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>>
>>> import multiprocessing
>>> import uuid
>>>
>>> def test():
... print str(uuid.uuid4())
...
>>> p = multiprocessing.Pool(processes=4)
>>> for x in xrange(0, 4):
... p.apply_async(test)
...
<multiprocessing.pool.ApplyResult object at 0x10056bb90>
<multiprocessing.pool.ApplyResult object at 0x10064e690>
<multiprocessing.pool.ApplyResult object at 0x10064e750>
<multiprocessing.pool.ApplyResult object at 0x10064e710>
>>> 62c76035-e340-41c4-86b4-908660b73bb7
62c76035-e340-41c4-86b4-908660b73bb7
62c76035-e340-41c4-86b4-908660b73bb7
62c76035-e340-41c4-86b4-908660b73bb7
In Linux:
gmr@binti ~ $ python
Python 2.6.4 (r264:75706, Mar 9 2010, 17:27:45)
[GCC 4.1.2 (Gentoo 4.1.2 p1.0.2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing
>>> import uuid
>>>
>>> def test():
... print str(uuid.uuid4())
...
>>> p = multiprocessing.Pool(processes=4)
>>> for x in xrange(0, 4):
... p.apply_async(test)
...
<multiprocessing.pool.ApplyResult object at 0x7dd990>
<multiprocessing.pool.ApplyResult object at 0x86d310>
<multiprocessing.pool.ApplyResult object at 0x86d390>
<multiprocessing.pool.ApplyResult object at 0x86d410>
>>> 6121782c-008d-42db-9df5-bbf619fb6568
ee7d3ef8-1c54-4ab5-bf06-1eddf5bcf2cb
40efe282-65a5-4160-96ee-b4cc0d14029d
9eb799f2-a46c-41e8-901f-423177f3467d
|