arifulhaqueuc / python-multithreading-examples

Python Scripts on Multithreading. This repo shows us various usage of Python's threading module with different sets of requirements.
MIT License
46 stars 26 forks source link
multithreading pep8 python2 threading

[this repository is under active development with a target completion time by Feb 2019]

About The Project

Topic Description
About the topic Multi-threading in Python has been recognized one of its most significant limitations. In this repository, I have tried to use Python's threading module with several scripts to show its usefulness in many diferrent forms.
Target Audience Developers who already have a good understand of Python programming (version 2.x in particular for this repo) and would like to know in details about Python's Threading module.
Purpose(s) This repository helps us understand different usage of Python's threading module with various requirements.
What to expect Practicing all given scripts would help the developers to have a very solid understanding of Python's threading module, and to get an ability to implement Python multithreaded appliation quickly and effectively.

List of Contents

Pre-requisites / Know Before You Go

Knowledge Base

As we all know, in general, running multiple threads simulteneously is equivalent to running several programs at the same time. In such case, threading in Python is a very popular process to attain concurrency and parallelism. Using threading module in a Python program gives us several key advatages such as sharing same data space and operating on light-weight process in order to avoid unnecessary memory overhead.

Repository Description

All the following files are avilable in the 'script' directory.
Please note that this description section may not be fully updated as of today as I update this section once a week. You might find more scripts in the acctual application directory. Each script has a concise in-script description of the program.

File Name Difficulty Devel Description
script_1 Beginner This program Print Hello World using threading.
script_2 Beginner This program adds two given numbers and prints the result.
script_3 Beginner This program outputs default thread name when the thread is being executed.
script_4 Beginner A Timer starts its work after a delay, and can be canceled at any point within that delay time period.
script_4_1 Beginner This program prints 1 to 10 with threading module.
script_4 Beginner This program handles timer function.
script_5 Beginner This program creates five threads and each thread prints a string with a two-second interval.
script_6 Beginner This program takes a string input from user and prints the input in a text file.
script_6_1 Beginner This program runs five times and each time the program takes two numbers as given input and prints sum of them.
script_7 TBD TBD
script_8 Beginner This program creates a thread, officially names it and tries to print the name.
script_9 Beginner This program prints output of square and cube of a series of numbers.
script_10 TBD TBD
script_11 Intermediate This program tries to access the values of args and kwargs.
script_12 TBD TBD

How to run

Support & Disclaimer

Support

Found a bug??
Here are the options

Interester in Collaboration and Contribution??
I am open to except any relevant collaboration suggestion from developers. Feel free to reach out to me in email.

General Disclaimer

This is my personal repo and not an official product of any company. If you would like to use this code, please keep it in your mind that, although I have tried to make it as error-free as possible, there's no warranty of a 100% bug free application.

Acknowledgment

This work is largely based on a number of great tutorials and resources all over the web, compiled by great people from very different domains. Without their effort and their will to make their hard work open access, i would have not been able to compile this tutorial.

References

TBD