We work on a linux server. When I type python, the information is as follow:
Code:
Python 2.6.6 (r266:84292, May 1 2012, 13:52:42)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
I think this is a CPython version,isn't it?
When I write a threading program, I found some threads would starve.
After some google, I realize there is a thing called GIL(Global Interpreter Lock) in CPython.
If I want to use multithreading in python, What would you suggest? Thanks in advance!
example code that create a thread, and one of the thread would starve in my linux.
Code:
import time
import threading, thread
class thread_reload_config(threading.Thread):
def run(self):
while True:
print("thread to reaload logging config file")
time.sleep(5)
def main():
print("enter main function")
t = thread_reload_config()
t.start()
while True:
print("still running")
time.sleep(3)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
exit(0)