My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Tutorial  
python-csp tutorial (front page).
Featured, Phase-Support, Tutorial
Updated Jul 24, 2010 by mount.sarah

This page should give you an birds-eye view of CSP and the python-csp library. The tutorial pages that follow take you through installing the library and using it in some detail, with several medium sized example programs (and exercises!).

What is CSP?

Concurrent and parallel programming are generally seen as "difficult" tasks. This is partly because most people have a mental model of how computers work which is fundamentally sequential, and partly because concurrent programs are susceptible to errors such as race hazards, deadlocks, and so on.

CSP stands for Communicating Sequential Processes, which is a framework for writing concurrent or program via message passinge. The advantage of message passing is that it makes race hazards impossible and provides a model of concurrency that is much easier to think about and more fun to program with.

Why CSP for Python?

Python currently has some support for threaded concurrency via the thread and threading module, support for parallel programming and the processing module. Threads are very low level, difficult to work with and cannot take advantage of multicore architectures that are now becoming commonplace. The processing module provides good support for process and thread-safe data structures but neither provide support for the message passing paradigm of programming and the sorts of constructs common to CSP style languages (such as OCCAM, OCCAM-pi, JCSP, C++CSP and so on). python-csp is design to plug this gap and also to provide an idiomatically pythonic implementation of the ideas in CSP.

CSP resources

Other concurrency packages for Python

  • PyCSP is another CSP library for Python, and somewhat similar to python-csp. In the medium term it is intended that PyCSP and python-csp will merge.
  • Trellis reactive programming for Python
  • STM software transactional memory for Python
  • Kamaelia message passing concurrency using asynchronous channels
  • Twisted event-driven Python programming
  • Multiprocessing this is the best support in the current standard library for running forked processes.

Moving on: a python-csp tutorial

The rest of this tutorial assumes that you can already write Python code. If not, read The Python Tutorial before you continue.

  • Advanced:
    • TutorialPage9 -- Debugging python-csp programs with extra tool support
    • TutorialPage10 -- Reactive (or dataflow) programming with python-csp

Sign in to add a comment
Powered by Google Project Hosting