My code has a loop which checks a list and if there are items in the list it will process them and remove them from the list. The items are continuously inserted into the list by another thread.
Here is the code:
for item in list:
It seems that the queue module will be useful for you. It implements multi-producer, multi-consumer queues and allows synchronize between threads without busy waiting.
see also Solution to producer and consumer problem in python which uses this