| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
- <title>Python processing</title>
- <meta name="author" content="R Oudkerk" />
- <link rel="stylesheet" href="doc/html4css1.css" type="text/css" />
- </head>
- <body>
- <div class="document" id="python-processing">
- <h1 class="title">Python processing</h1>
- <table class="docinfo" frame="void" rules="none">
- <col class="docinfo-name" />
- <col class="docinfo-content" />
- <tbody valign="top">
- <tr><th class="docinfo-name">Author:</th>
- <td>R Oudkerk</td></tr>
- <tr><th class="docinfo-name">Contact:</th>
- <td>roudkerk at users.berlios.de</td></tr>
- <tr class="field"><th class="docinfo-name">Url:</th><td class="field-body"><a class="reference" href="http://developer.berlios.de/projects/pyprocessing">http://developer.berlios.de/projects/pyprocessing</a></td>
- </tr>
- <tr><th class="docinfo-name">Version:</th>
- <td>0.52</td></tr>
- <tr class="field"><th class="docinfo-name">Licence:</th><td class="field-body">BSD Licence</td>
- </tr>
- </tbody>
- </table>
- <p><tt class="docutils literal"><span class="pre">processing</span></tt> is a package for the Python language which supports the
- spawning of processes using the API of the standard library's
- <tt class="docutils literal"><span class="pre">threading</span></tt> module. It runs on both Unix and Windows.</p>
- <p>Features:</p>
- <ul class="simple">
- <li>Objects can be transferred between processes using pipes or
- multi-producer/multi-consumer queues.</li>
- <li>Objects can be shared between processes using a server process or
- (for simple data) shared memory.</li>
- <li>Equivalents of all the synchronization primitives in <tt class="docutils literal"><span class="pre">threading</span></tt>
- are available.</li>
- <li>A <tt class="docutils literal"><span class="pre">Pool</span></tt> class makes it easy to submit tasks to a pool of worker
- processes.</li>
- </ul>
- <div class="section">
- <h1><a id="links" name="links">Links</a></h1>
- <ul class="simple">
- <li><a class="reference" href="./doc/index.html">Documentation</a></li>
- <li><a class="reference" href="./doc/INSTALL.html">Installation instructions</a></li>
- <li><a class="reference" href="./doc/CHANGES.html">Changelog</a></li>
- <li><a class="reference" href="./doc/THANKS.html">Acknowledgments</a></li>
- <li><a class="reference" href="./doc/COPYING.html">BSD Licence</a></li>
- </ul>
- <p>The project is hosted at</p>
- <ul class="simple">
- <li><a class="reference" href="http://developer.berlios.de/projects/pyprocessing">http://developer.berlios.de/projects/pyprocessing</a></li>
- </ul>
- <p>The package can be downloaded from</p>
- <ul class="simple">
- <li><a class="reference" href="http://developer.berlios.de/project/filelist.php?group_id=9001">http://developer.berlios.de/project/filelist.php?group_id=9001</a> or</li>
- <li><a class="reference" href="http://pypi.python.org/pypi/processing">http://pypi.python.org/pypi/processing</a></li>
- </ul>
- </div>
- <div class="section">
- <h1><a id="examples" name="examples">Examples</a></h1>
- <p>The <tt class="docutils literal"><span class="pre">processing.Process</span></tt> class follows the API of <tt class="docutils literal"><span class="pre">threading.Thread</span></tt>.
- For example</p>
- <pre class="literal-block">
- from processing import Process, Queue
- def f(q):
- q.put('hello world')
- if __name__ == '__main__':
- q = Queue()
- p = Process(target=f, args=[q])
- p.start()
- print q.get()
- p.join()
- </pre>
- <p>Synchronization primitives like locks, semaphores and conditions are
- available, for example</p>
- <pre class="literal-block">
- >>> from processing import Condition
- >>> c = Condition()
- >>> print c
- <Condition(<RLock(None, 0)>), 0>
- >>> c.acquire()
- True
- >>> print c
- <Condition(<RLock(MainProcess, 1)>), 0>
- </pre>
- <p>One can also use a manager to create shared objects either in shared
- memory or in a server process, for example</p>
- <pre class="literal-block">
- >>> from processing import Manager
- >>> manager = Manager()
- >>> l = manager.list(range(10))
- >>> l.reverse()
- >>> print l
- [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
- >>> print repr(l)
- <Proxy[list] object at 0x00E1B3B0>
- </pre>
- <p>Tasks can be offloaded to a pool of worker processes in various ways,
- for example</p>
- <pre class="literal-block">
- >>> from processing import Pool
- >>> def f(x): return x*x
- ...
- >>> p = Pool(4)
- >>> result = p.mapAsync(f, range(10))
- >>> print result.get(timeout=1)
- [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
- </pre>
- <a href="http://developer.berlios.de" title="BerliOS Developer">
- <img src="http://developer.berlios.de/bslogo.php?group_id=9001"
- width="124px" height="32px" border="0" alt="BerliOS Developer Logo"></a></div>
- </div>
- </body>
- </html>
|