The reason for your MemoryError
exception is the following: your input video file gets loaded in memory in its entirety prior to be processed for to be sent off to the remote service:
def createMethod(methodName, methodDesc, rootDesc, schema):
...
def method(self, **kwargs):
...
if media_filename:
...
if media_upload.resumable():
...
else:
# A non-resumable upload
if body is None:
...
else:
...
payload = media_upload.getbytes(0, media_upload.size())
...
Instead of uploading videos in one go, I'd very much recommend to use resumable uploads by means of the time-tested public Google script upload_video.py
. (This script has an official documentation too. To obtain a self-explanatory usage information page from the script just issue it with the command line option --help
.)
If you're using Python 3 (your code suggests that) then you have to convert that script to Python 3, because it's written for Python 2. For this, see the section Patching upload_video.py
of one answer of mine.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…