토네이도를 사용하여 파일 업로드 서비스를 만들려고합니다.토네이도 파일 업로드가 차단됩니다.
그러나 여러 사용자가 파일을 업로드 할 때 토네이도가 처음으로 완료되어 다음 파일을 처리하는 것을 기다리는 것으로 나타났습니다.
토네이도에서 ASYNC 파일 업로드를 수행하는 적절한 방법은 무엇입니까?
내 게시물 :
@tornado.web.asynchronous
def post(self):
list_of_img = ['png','jpg','jpeg','gif']
list_of_files = ['rtf','txt','ppt','pptx','doc','docx','pdf','xls','xlsx','rar','zip','tgz','bz','gz','tar','bz2','3gp','mp4','m15','avi','mp3']
path = __UPLOADS__
try:
fileinfo = self.request.files['file'][0]
filebody = fileinfo['body']
filename = fileinfo['filename']
filetype = fileinfo['content_type']
extn = os.path.splitext(filename)[1]
n_filename = str(uuid.uuid4()) + extn
# rcv file
print "saving", n_filename + "..."
output_file = open(n_filename, 'w')
output_file.write(filebody)
# upload to s3
print "uploading", n_filename + "..."
self.upload(path, n_filename)
# clean up
print "cleaning", n_filename + "..."
self.delete_local(n_filename)
self.finish(n_filename)
except KeyError, key:
delete = self.get_argument("delete", None, True)
if delete:
filename = self.get_argument("filename", None, True)
print "deleting", filename + "..."
self.delete(path, filename)
self.finish(filename)
어떻게 제대로 수행 할 수 있습니까? – majidarif
큰 질문입니다. 시스템의 모든 차단 부분을 식별하고이를 비 차단 동등 물로 교체해야합니다. 이는 일반적으로 비동기 적으로 사용되도록 설계된 네트워크 라이브러리를 제외한 모든 네트워킹 라이브러리를 사용할 수 없음을 의미합니다. 무료 점심은 여기에 없습니다. 인터페이스 변경은 비동기 적이라는 것을 의미합니다. –
심각하게. 이것은 일반적인 문제이며 비동기 파일 업로드를 처리하기위한 최선의 방법을 찾을 수 없습니다. BTW, 토네이도에 내 완벽한 응용 프로그램을 작성하기 전에 몇 가지 문제를 찾을 수 있습니다. –