سؤال

أحصل على خطأ في الخطأ "عند فتحه ويقرأ ملف أكبر من 500 ميغابايت. إذا كان أقل من 500 ميغابايت يعمل تماما .. أنا باستخدام الحجم الخاص بي بقيار التقدم MaxValue giveacodicetagpre.

هل كانت مفيدة؟

المحلول

Don't use the read() method since it reads the whole file into a string. You should use the os.stat() function to get the the file metadata, which returns a stat structure with the member st_size. That's the size in bytes of the file. You don't have to read it all in first.

For sending, also read in and write out in chunks (say 16kB), in a loop.

نصائح أخرى

So, filein.read() actually reads (i.e. downloads) the file and is consuming your memory.
You can instead use

self.size = self.ftp.size(self.filename)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top