|
Tutorial
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
Moving on: a python-csp tutorialThe rest of this tutorial assumes that you can already write Python code. If not, read The Python Tutorial before you continue.
|