How to set 'timeout' I use urllib2.urlopen instead urlfetch?

161 views
Skip to first unread message

Xi Shen

unread,
Oct 9, 2011, 4:57:11 AM10/9/11
to google-a...@googlegroups.com
GAE currently uses python 2.5, and the urllib2.urlopen has a different signature than it is in python 2.7, that is in python 2.5 it does not support the 'timeout' argument. Can I just use the 'socket.setdefaulttimeout' ?

I do not want to switch to urlfetch, because it make the unite test inconvenient.

Timofey Koolin

unread,
Oct 9, 2011, 6:35:27 AM10/9/11
to google-a...@googlegroups.com
Wait until next SDK will release - it will be support python 2.7

2011/10/9 Xi Shen <david...@gmail.com>
GAE currently uses python 2.5, and the urllib2.urlopen has a different signature than it is in python 2.7, that is in python 2.5 it does not support the 'timeout' argument. Can I just use the 'socket.setdefaulttimeout' ?

I do not want to switch to urlfetch, because it make the unite test inconvenient.

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/ybVWKrhivIYJ.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.



--
С уважением,
Кулин Тимофей.

Телефон: +7 (4852) 974793
ICQ: 114902104
email: tim...@koolin.ru
Blog: http://timofey.koolin.ru

Tim Hoffman

unread,
Oct 9, 2011, 6:42:09 AM10/9/11
to google-a...@googlegroups.com
Hi 

Currently you set it globally with urlfetch.set_default_fetch_deadline(n)  
You can also query the current value with get_default_fetch_deadline

Rgds

Tim

Xi Shen

unread,
Oct 9, 2011, 9:29:03 PM10/9/11
to google-a...@googlegroups.com
Thanks Tim :)

And to my amusement, this function is not added till SDK 1.5.3. Did Google never thought people needs to set the timeout value before? Or the urlfetch module has some advantages that most people choose to use it and avoided the issue?

Tim Hoffman

unread,
Oct 10, 2011, 4:17:55 AM10/10/11
to google-a...@googlegroups.com
HI

Umm it was requested, but also for support for urllib2 took a while.

Also urlfetch allows for async fetching which you can't do directly with urllib, so unless people where using existing
libs (ie a soap client) you where always better off using urlfetch.

Thanks

Tim
Reply all
Reply to author
Forward
0 new messages