1. Why "retry_count" repeated 2 times here? 
2. You really can't have global counters in this func. In case we'll be uploading two files in multithreaded django environment, this code will shoot us in the leg pretty hard. If you want a counter for all threads uploading same file - send counter object when all these threads start.