470,596 Members | 1,450 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

Resolving 10060, 'Operation timed out'

Does anyone know how to prevent this error from occurring: IOError:
[Errno socket error] (10060, 'Operation timed out').

I am using the following code without any luck. Obviously I am missing
something.

import socket
socket.setdefaulttimeout(20)

Thank you in advance.

Tom Williams

Jul 19 '05 #1
3 7856
My manual says that socket has a settimeout(value) but I don't
seem to find anything on socket.setdefaulttimeout method you
refer to.

<snip>
settimeout( value)

Set a timeout on blocking socket operations. The value argument can be a
nonnegative float expressing seconds, or None. If a float is given, subsequent
socket operations will raise an timeout exception if the timeout period value
has elapsed before the operation has completed. Setting a timeout of None
disables timeouts on socket operations. s.settimeout(0.0) is equivalent to
s.setblocking(0); s.settimeout(None) is equivalent to s.setblocking(1). New in
version 2.3.

-Larry Bates

willitfw wrote:
Does anyone know how to prevent this error from occurring: IOError:
[Errno socket error] (10060, 'Operation timed out').

I am using the following code without any luck. Obviously I am missing
something.

import socket
socket.setdefaulttimeout(20)

Thank you in advance.

Tom Williams

Jul 19 '05 #2
Larry Bates wrote:
My manual says that socket has a settimeout(value) but I don't
seem to find anything on socket.setdefaulttimeout method you
refer to.


Larry, the module has a setdefaulttimeout() function,
while socket objects themselves have a settimeout().

To the OP: did you already create your socket object
before you called setdefaulttimeout()? That setting
applies only to *new* sockets created after you call
the function...

-Peter
Jul 19 '05 #3
willitfw wrote:
I'm including the code that I've been using. I am relatively new to
python, and not sure if a socket was created:

*****************
import socket

socket.setdefaulttimeout(None)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)


The last line above creates a socket... and I suspect
the line ahead of it is redundant.

More importantly, you can probably avoid using
the defaulttimeout thing if you just do settimeout
on the newly created socket...
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Ajay Abhyankar | last post: by
1 post views Thread by Joško Šugar | last post: by
5 posts views Thread by Sachin Surana | last post: by
11 posts views Thread by Sumit Acharya | last post: by
10 posts views Thread by Jim Underwood | last post: by
reply views Thread by Jinshi | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.