पायथन 3.2 ने new GIL implementation एंटोनी पिट्रो द्वारा प्रस्तुत किया जो sys.setswitchinterval
फ़ंक्शन का खुलासा करता है।पायथन 3.2 में sys.setswitchinterval और
यह कब बदलना उपयोगी होगा, और क्यों?
sw_interval = sys.getswitchinterval()
try:
# Setting the switch interval to a very big number to make sure that their will be no
# thread context switching while running the operations that came after.
sys.setswitchinterval(sys.maxint)
# Expressions run here will be atomic ....
finally:
sys.setswitchinterval(sw_interval)
एक और उपयोग के मामले अपने कोड खास तौर पर जब आप convoy effect (या किसी भी बढ़त का सामना कर रहे धुन पर होगा:
कोई लेकर्स नहीं ?! 50 प्रतिनिधि एक बार जा रहे हैं ... –