Fix issue with uploading image to glance on Python3
It was unable to upload image when horizon was running on python3, there was a problem with closed file in new thread. This commit is fixing this issue with added if clause whether horizon running on python2 or python3 and correctly call close_called on file when running on python3. Change-Id: Ice178f6269ac527ba62b26d86976b5336987c922 Closes-Bug: #1773935
This commit is contained in:
parent
6517caf810
commit
b84da5e84e
@ -525,7 +525,10 @@ def image_create(request, **kwargs):
|
||||
return ExternallyUploadedImage(image, request)
|
||||
elif isinstance(data, TemporaryUploadedFile):
|
||||
# Hack to fool Django, so we can keep file open in the new thread.
|
||||
data.file.close_called = True
|
||||
if six.PY2:
|
||||
data.file.close_called = True
|
||||
else:
|
||||
data.file._closer.close_called = True
|
||||
elif isinstance(data, InMemoryUploadedFile):
|
||||
# Clone a new file for InMemeoryUploadedFile.
|
||||
# Because the old one will be closed by Django.
|
||||
|
Loading…
x
Reference in New Issue
Block a user