socket.setdefaulttimeout doesn't work in Windows - any updates?

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Mossy Offline
Senior Member
Posts: 202
Joined: Oct 2011
Reputation: 25
Post: #1
This issue was raised a couple of years ago - http://trac.xbmc.org/ticket/10960 - and I've noticed that at least some of the current plugins that use setdefaulttimeout, don't call it when running under Windows.

E.g. from the bbc iplayer plugin:
Code:
.       environment = os.environ.get( "OS", "xbox" )
        try:
            timeout = int(__addon__.getSetting('socket_timeout'))
        except:
            timeout = 5
        if environment in ['Linux', 'xbox'] and timeout > 0:
            setdefaulttimeout(timeout)

Is this still necessary? Is there a best practice documented for this? E.g. the bbc iplayer seems to exclude all platforms except xbox and those that are linux-based, so what about iOS etc.?
find quote
AddonScriptorDE Offline
Fan
Posts: 310
Joined: May 2012
Reputation: 15
Location: Germany
Post: #2
I think, this is only needed for the xbox. When using urllib2 to receive the response, the default timeout is 5 seconds. You can set the timeout with:
Code:
response = urllib2.urlopen(request,timeout=30)
socket.setdefaulttimeout(timeout) seems to do the same...

cheers,
asde
(This post was last modified: 2012-06-19 20:22 by AddonScriptorDE.)
find quote