Open peetonn opened 9 years ago
I'm not too experienced with threading in python, so I don't know if I can help too much.
Could you post the output when it freezes using {'verbose':True, 'skip_download':True, 'logger': MyLogger(), 'noplaylist':True, 'youtube_include_dash_manifest':False}
. It would be interesting to know if it always get stuck in the same place.
You are using a global variable for saving the output (outputMsg
), that isn't a good way for handling it. Instead you should use ydl.extract_info(url, download=False)
, which returns a dictionary with an url
key (with that some of the parameters you use are no longer needed).
the weirdest thing is that it gets stuck in different places, sometimes here, or here, or other places. I tend to blame environment, however can't figure out what could be the problem exactly. Also it could be that youtube-dl is making some non-thread safe calls from other libraries which somehow interferes with the environment.
Thanks for the hint about the extract_info
by the way!
Run it under debugger and issue pause after it's stuck, look at the threads' stack frames to see who has actually stuck and where.
I'm using youtube-dl script in some python environment where I can't execute
download
on the main thread as it will block the UI. So I'm creating thread whenever I need to fetch video URL (I only need youtube video URL extracted from youtube video webpage URL). What I observe right now - sometimes (1 out of 200-300 requests) everything just freezes as it could happen with mutual thread blocking. I tried to debug it, and it seems that hangs are happening randomly. It may also be the environment in which I'm running this code. So, I'm wondering, is it safe to execute the following code in other than main thread?Brief description:
getVideoUrlAsync
is called from the main thread and youtube video page url is placed intoserviceUrlQ
. New thread created, it calls youtube-dl code to fetch video URL and places it intooutQ
(orvideoUrlQ
).