Commits

Anonymous committed bf9f240

Minor notes and modifications

Comments (0)

Files changed (3)

src/CoroutinesAndConcurrency.rst

    GIL: Global Interpreter Lock
 
 ********************************************************************************
-Coroutines & Concurrency
+Coroutines, Concurrency & Distributed Systems
 ********************************************************************************
 
 Primary focus should be on:
 
 foo bar :func:`input` baz.
 
+Multiprocessing
+===============================================================================
+
+Example by Michele Simionato in comp lang python.
+Here is an example of using multiprocessing (which is included
+in Python 2.6 and easy_installable in older Python versions)
+to print a spin bar while a computation is running::
+
+    import sys, time
+    import multiprocessing
+    DELAY = 0.1
+    DISPLAY = [ '|', '/', '-', '\\' ]
+    def spinner_func(before='', after=''):
+        write, flush = sys.stdout.write, sys.stdout.flush
+        pos = -1
+        while True:
+            pos = (pos + 1) % len(DISPLAY)
+            msg = before + DISPLAY[pos] + after
+            write(msg); flush()
+            write('\x08' * len(msg))
+            time.sleep(DELAY)
+    def long_computation():
+        # emulate a long computation
+        time.sleep(3)
+    if __name__ == '__main__':
+        spinner = multiprocessing.Process(
+            None, spinner_func, args=('Please wait ... ', ''))
+        spinner.start()
+        try:
+            long_computation()
+            print 'Computation done'
+        finally:
+            spinner.terminate()
+
 Further Reading
 ================================================================================
 
     that functional languages don't help that much with this problem.
 
     http://jessenoller.com/2009/02/01/python-threads-and-the-global-interpreter-lock/
-        
+
+.. Good introduction to Twisted:
+.. http://jessenoller.com/2009/02/11/twisted-hello-asynchronous-programming/
+
+.. Also
+.. http://jessenoller.com/2009/02/02/an-interview-with-adam-olsen-author-of-safe-threading-completely-different/

src/PythonDecorators.rst

     http://www.siafoo.net/article/68
 
     http://www.ddj.com/web-development/184406073
-	Philip Eby introduces decorators. 
+	Philip Eby introduces decorators.
 
     http://www.informit.com/articles/article.aspx?p=1309289&seqNum=4
 	Class Decorators.
 	Class decorators
 
 .. Examples http://www.python.org/dev/peps/pep-0318/#examples
+
+.. Peek inside a decorated function:
+.. http://groups.google.com/group/comp.lang.python/browse_thread/thread/0fb2ee45dbc101b1

src/PythonForProgrammers.rst

 	Building a Virtual Environment for Running Python 3:
 	http://pypi.python.org/pypi/virtualenv
 
+	Excellent Newsfeed Following Python Articles from Everywhere:
+	http://www.planetpython.org/
+
 
 .. Good description of the Python packaging system:
 .. http://nameless-sorrows.blogspot.com/2009/02/custom-namespacing-system-for-python.html
 
 .. Getters and setters in Python:
 .. http://eli.thegreenplace.net/2009/02/06/getters-and-setters-in-python/
+
+.. The 'with' statement (might require a separate chapter?):
+.. http://jessenoller.com/2009/02/03/get-with-the-program-as-contextmanager-completely-different/