Login Register






multithreading in python filter_list
Author
Message
multithreading in python #1
i have learn to use multithreading in c/c++ but i couldn't get through using it in python or how to use it. Can someone help me on that please or recommend a tutorial or white paper on threading in python . All i have notice on it from several codes is using an instance of the thread module as argument to a class as in "class run(thread.Threading):". Am using python 2.7 win32, any help is appreciated.

Reply

multithreading in python #2
i have learn to use multithreading in c/c++ but i couldn't get through using it in python or how to use it. Can someone help me on that please or recommend a tutorial or white paper on threading in python . All i have notice on it from several codes is using an instance of the thread module as argument to a class as in "class run(thread.Threading):". Am using python 2.7 win32, any help is appreciated.

Reply

RE: multithreading in python #3
Hello sir, your question meets my interests. I would like to try help you. This is a sample run of a very basic example of multithreading script I just wrote now to show you.


Spoiler: <span style="font-weight: bold;" class="mycode_b">Code</span>
Code:
## Importing from threading import Thread ## Setting a list to gather the threads for joining thread_list = [] ## Function to use with each thread def func(x, y): print "{} + {} = {}".format(x, y, x+y) ## General loop for item in ((1, 2), (3, 4), (5, 6), (7, 8), (9, 10)): ## Thread Proper Implementation thread = Thread(target=func, args=((item[0], item[1], ))) ## Making each thread daemonic so they will be able to run ## on the background without affecting surely the main program ## execution thread.daemon = True ## Start the each thread thread.start() ## Put it to the list thread_list.append(thread) ## Wait till all the threads are done for thread in thread_list: thread.join()



Spoiler: <span style="font-weight: bold;" class="mycode_b">Image</span>
[Image: 1jtUTWr.png]




I hope this helped out a little, if anything more you want to know or generally anything you would like to ask me please feel free doing it!
Kind Regards.
MASTERING OTHERS IS STRENGTH, MASTERING YOURSELF IS TRUE POWER.

[Image: qJweLN6.jpg]

Reply

RE: multithreading in python #4
Hello sir, your question meets my interests. I would like to try help you. This is a sample run of a very basic example of multithreading script I just wrote now to show you.


Spoiler: <span style="font-weight: bold;" class="mycode_b">Code</span>
Code:
## Importing from threading import Thread ## Setting a list to gather the threads for joining thread_list = [] ## Function to use with each thread def func(x, y): print "{} + {} = {}".format(x, y, x+y) ## General loop for item in ((1, 2), (3, 4), (5, 6), (7, 8), (9, 10)): ## Thread Proper Implementation thread = Thread(target=func, args=((item[0], item[1], ))) ## Making each thread daemonic so they will be able to run ## on the background without affecting surely the main program ## execution thread.daemon = True ## Start the each thread thread.start() ## Put it to the list thread_list.append(thread) ## Wait till all the threads are done for thread in thread_list: thread.join()



Spoiler: <span style="font-weight: bold;" class="mycode_b">Image</span>
[Image: 1jtUTWr.png]




I hope this helped out a little, if anything more you want to know or generally anything you would like to ask me please feel free doing it!
Kind Regards.
MASTERING OTHERS IS STRENGTH, MASTERING YOURSELF IS TRUE POWER.

[Image: qJweLN6.jpg]

Reply

RE: multithreading in python #5
http://www.tutorialspoint.com/python/pyt...eading.htm
http://pymotw.com/2/threading/
http://inventwithpython.com/blog/2013/04...readworms/
http://www.troyfawkes.com/learn-python-m...es-basics/
[Image: OilyCostlyEwe.gif]

Reply

RE: multithreading in python #6
http://www.tutorialspoint.com/python/pyt...eading.htm
http://pymotw.com/2/threading/
http://inventwithpython.com/blog/2013/04...readworms/
http://www.troyfawkes.com/learn-python-m...es-basics/
[Image: OilyCostlyEwe.gif]

Reply

RE: multithreading in python #7
Thanks very much pyscho_coder and LoaD1nG. the code was very helpful especially the links, it was guiding. Thanks for the help.

Reply

RE: multithreading in python #8
Thanks very much pyscho_coder and LoaD1nG. the code was very helpful especially the links, it was guiding. Thanks for the help.

Reply

RE: multithreading in python #9
(09-29-2014, 07:22 AM)hackejima Wrote: Thanks very much pyscho_coder and LoaD1nG. the code was very helpful especially the links, it was guiding. Thanks for the help.

You are very welcome, also make sure you put the '@' simbol before you mention a member's name so we get a notification that you mentioned us and we respond as fast as possible.

Like this @hackejima .
Cheers!

NOTE: the 'o' in my name is a zero just to let you know for further mentioning in any case.
MASTERING OTHERS IS STRENGTH, MASTERING YOURSELF IS TRUE POWER.

[Image: qJweLN6.jpg]

Reply

RE: multithreading in python #10
(09-29-2014, 07:22 AM)hackejima Wrote: Thanks very much pyscho_coder and LoaD1nG. the code was very helpful especially the links, it was guiding. Thanks for the help.

You are very welcome, also make sure you put the '@' simbol before you mention a member's name so we get a notification that you mentioned us and we respond as fast as possible.

Like this @hackejima .
Cheers!

NOTE: the 'o' in my name is a zero just to let you know for further mentioning in any case.
MASTERING OTHERS IS STRENGTH, MASTERING YOURSELF IS TRUE POWER.

[Image: qJweLN6.jpg]

Reply