urllib2 socket timeout
#1
Hi,

I'm a Python coder who got asked to look t a strange error insde a plugin. The plugin calls script.module.parsedom, which has a fetchPage() def inside of it that is nothing more than a urllib2 wrapper. What I discovered is that certain boxes, all happened to be Raspberry Pis running RaspBMC, using 13.2. Long story short is that certain calls made using this fetchPage() wrapper from the parsedom module work fine. All of a sudden, you'll get an immediate socket.Timeout, for no reason, even though the plugin overrids the default socket.Timeout and sets it at 20 seconds. I tried to manually replicate this by copying fetchPage() out of CommonFunctions.py in script.module.parsedom and was unstable to reproduce the error. The page it times out on is a very simple HTTP form that posts a few variables and receives response back. Strange thing is that I use this plugin, as well, and I was able to use this person's login details. They could not use mine, having the same error.

http://pastebin.com/KyQnxD8J

From trying to figure this out, it looks as if the Python 2.7.2 in 13.2 is using a version of urllib2 that has known to leak socket.Timeout and can behave randomly. Any suggestions? It's not my code but I suggested trying out using the requests module instead, if a rewrite of fetchPage() were the route. I can't replicate the error using my working Pi, nor can the code on my system, that I also tried using his. This error only occurs inside his 13.2 instance but has now been verified with a few others, all seeing to run Raspberry Pis but definitely not all or most.

Thanks.
Reply

Logout Mark Read Team Forum Stats Members Help
urllib2 socket timeout0