The code posted below initiates a single Thread that fires up 4 cores on my macbookpro. Is there a way to limit to how many cores the thread should be using?
import threading
import logging
logging.basicConfig(level=logging.DEBUG, format='(%(threadName)s) %(message)s',)
def func():
logging.debug('starting')
m=0
for i in range(500000000):
m+=i
logging.debug('exiting')
thread = threading.Thread(target=func)
thread.start()
logging.debug('completed')
Here is the log:
Loaded sitecustomize.py
(Thread-1) starting
(MainThread) completed
(Thread-1) exiting
[Finished in 128.0s]