Week 2: threading with Python

I’ve got a new idea!
I am still quite new to threading in Python but I have come up with a way to do it.

My idea to start with:
Every time I return home from either; university, a day out with some friends or some shopping at my local Tesco EXTRA, I will plug a USB into the Pi. Now this is not just any old USB stick that holds Cat Memes, or a death destroying program which delete system32 with admin privileges all in a split second you plug that USB into a computer… Nope… none of those!

But… what’s the point in having to always plug a USB into a Pi when you return home??

Well, my previous idea was to make a checkbox, which once checked would turn off and deactivate the program until unchecked. Although, I found that idea quite unreliable!
Since my webpage is online and open to anyone and everyone who knows the URL, I have to think about securing my program. Obviously, this can be easily fixed if I add a password to the webpage, but to give it that extra step of security I’ve decided to use a Master Key. If the USBs not plugged into the Raspberry Pi, then the program will be completely useless. because… why would I want my lights on when I am not at home! *cough* *cough* home surveillance… but that’s a whole new idea that I will not go into… yet!

Through my research, I have found out that the best way to allow a Python program to check if a USB is plugged into a USB slot!

What is threading and how can I use it in a program?

Threading allows you to run multiple tasks or functions AT THE SAME TIME!?!

Although, some people get confused, thinking that threading allows the use to execute different tasks/functions on different CPUs.
This is not the case!

Python threads will NOT make your program faster if it already uses 100 % CPU time.”  WIKIBOOKS – 6 October 2015
– Code and a more depth explanation can be found here! – https://en.wikibooks.org/wiki/Python_Programming/Threading

and with that in mind, let me show you how to do this in Python!

Please do let me know how it goes, and if you have any questions or issues, feel free to contact me at: jamesdibnah@gmail.com

HAPPY CODING!

Leave a Reply

3 Comments on "Week 2: threading with Python"

Notify of
avatar
Sort by:   newest | oldest | most voted
Matt
Guest

So you are essentially create a physical key for your program? That’s a pretty neat idea. Like a car key I guess?

trackback

[…] my previous post I mentioned that while researching different programming techniques, I found a way to run two […]

wpDiscuz