| 1 |
import time, threading |
|---|
| 2 |
from django.core.files.base import ContentFile |
|---|
| 3 |
from django.core.files.storage import FileSystemStorage |
|---|
| 4 |
temp_storage = FileSystemStorage(location="/tmp/files") |
|---|
| 5 |
|
|---|
| 6 |
class SlowFile(ContentFile): |
|---|
| 7 |
def chunks(self): |
|---|
| 8 |
print "Asked for chunks" |
|---|
| 9 |
time.sleep(2) |
|---|
| 10 |
print "Returning chunks" |
|---|
| 11 |
return super(ContentFile, self).chunks() |
|---|
| 12 |
|
|---|
| 13 |
def save(data): |
|---|
| 14 |
temp_storage.save('conflict', SlowFile(data)) |
|---|
| 15 |
|
|---|
| 16 |
threading.Thread(target=save, args=("Content 1",)).start() |
|---|
| 17 |
#time.sleep(5) |
|---|
| 18 |
save("Content2") |
|---|