Gist of the Day: Threading in Python with All the Trimmings

Today I took on a rather ambitious Gist, and as a result the write-up is going to be rather minimal (I still have three miles that aren’t going to run themselves).
The Gist today is just a variation on the Python script I did before to load a CSV file into a MongoDB collection, but now it’s multi-threaded.
Please note that I’m sure that I’ve done something wrong here, but I’m trying to use the Semaphore to limit the number of threads running against MongoDB. I’m also using locks for print since I/O is still serial.
If you do see I’ve done something wrong, I sincerely invite your constructive criticism.


I am really enjoying Python, and the threading in Python is neat. I haven’t done a whole bunch with threading in the past, but I reckon it’s about time I learn more about it.
VERY BIG thank you goes out to the folks on for their help (and their willingness to graciously help me find my own silly mistakes).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.