karamanolev / WhatManager2

Torrent management system based on Django and Transmission
MIT License
153 stars 25 forks source link

random directory creating isn't really random #96

Open mlapaglia opened 7 years ago

mlapaglia commented 7 years ago

When multiple transcodes start at the same time, the random int method is returning the same value for multiple directories when concurrency is set higher than 1 in the celery script. Currently it fails because it detects the folder already exists from another worker and halts transcoding. Would adding the current milliseconds to the string help? Something like return TRANSCODER_TEMP_DIR + '_' + str(round(time.time() * 1000)) + '_' + str(random.randint(10000000, 99999999))

folder examples it creates are: whatup.celery.9758_1.50315276795e+12_88760908 and whatup.celery.9758_1.50315276602e+12_88760908