in Beginner, General, Programming, Python

Multi-threading in Python: A quick guide for python multithreading

All the resources for multi-threading python programming.

import threading

Thats all is there in python multi processing! Of course you should know what to use where? I found this great slideshare option that you should go through to get up and running in python multi processing. An Introduction to Python Concurrency.
Semaphore is the oldest parallel processing concepts. Which of course highly useful for any multi processing programs. For me it was a SPI Bus accessed using a raspberry pi. There are 4 chip selects and each communication event is a new thread. To provide access to a single bus, semaphore was used. Its implementation is straight forward in python.

parallelProc = threading.Semaphore(1) #parallelProc is the object that holds the semaphore and allows only one concurrent process.

now, it might get painful to get the acquire and release right, but otherwise it is great!

def communicationEvent():
print 'Doing bus transactions here!'

Finding time for adding more of the concepts in the future
One might think life just got easier with multi-threading, but thats when shit gets real! (Ned Stark way of telling)

Leave a Reply for #akrv Cancel Reply

Write a Comment



This site uses Akismet to reduce spam. Learn how your comment data is processed.