Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload_video.py - TypeError: argument of type 'NoneType' is not iterable #11

Open
GoogleCodeExporter opened this issue Jan 28, 2016 · 8 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. try to upload a 200mb video file
2. it errors.
3. im sad.

What is the expected output? What do you see instead?
Uploading file... and be done.

This seems unexpected:

    if 'id' in response:
TypeError: argument of type 'NoneType' is not iterable


What version of the product are you using? On what operating system?


Please provide any additional information below.

I suspect this hasn't been tested on files that need more than one chunk.
I think it is expected too loop, but instead it errors:

  while response is None:
    try:
      print "Uploading file..."
      status, response = insert_request.next_chunk()
      if 'id' in response:


Original issue reported on code.google.com by [email protected] on 6 May 2014 at 7:02

@GoogleCodeExporter
Copy link
Author

The sample code uses a chunksize of -1 (all at once):

https://code.google.com/p/youtube-api-samples/source/browse/samples/python/uploa
d_video.py#104

  media_body=MediaFileUpload(options.file, chunksize=-1, resumable=True)

so it never chunks, thus it never runs the chunking code, which is where this 
bug lives.

Original comment by [email protected] on 6 May 2014 at 9:47

@GoogleCodeExporter
Copy link
Author

I'm sad too
Any fix for that?

Thanks,

Original comment by tht2401 on 29 Oct 2014 at 2:13

@GoogleCodeExporter
Copy link
Author

Nope.

The same code (and bug) is also here:
https://github.com/youtube/api-samples/blob/master/python/upload_video.py#L131-L
135

I stared to work on a fix, but testing error handling is hard, so I just gave 
up and set chunksize=-1.

https://github.com/CarlFK/veyepar/blob/master/dj/scripts/youtube_v3_uploader.py#
L181

Original comment by [email protected] on 29 Oct 2014 at 3:15

@GoogleCodeExporter
Copy link
Author

I added a simple line of code, it worked beautifully (check None for response):

      .....
      status, response = insert_request.next_chunk()
      if response is not None:
        if 'id' in response:
      ...

Original comment by tht2401 on 29 Oct 2014 at 4:20

@GoogleCodeExporter
Copy link
Author

I think you moved the bug to this:

if error is not None:
print error
retry += 1
if retry > MAX_RETRIES:
exit("No longer attempting to retry.")

You don't set error, so it is still None, so retry will never get incremented, 
so it may loop forever.  

Which may be better than erroring, but still not right.  
I was hoping that by now someone would have fixed the code but I guess it isn't 
a priority. 

Original comment by [email protected] on 29 Oct 2014 at 4:29

@GoogleCodeExporter
Copy link
Author

I haven't looked at api code but I think that response will be None until the 
last chunk is sent.
error is not None only when we have an exception from 
insert_request.next_chunk()
The sample code has MAX_RETRIES so it won't loop forever.

Original comment by tht2401 on 29 Oct 2014 at 4:39

@GoogleCodeExporter
Copy link
Author

ah right, I see what you are saying. 

pretty please submit a pull request over on 
https://github.com/youtube/api-samples (you can do it by editing the code right 
there, click the edit link that takes you to
https://github.com/youtube/api-samples/edit/master/python/upload_video.py

Original comment by [email protected] on 29 Oct 2014 at 4:46

@GoogleCodeExporter
Copy link
Author

https://github.com/youtube/api-samples/pull/18

Original comment by tht2401 on 29 Oct 2014 at 4:58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant