3

I am running a crawler, it's working fine in MAC and Ubuntu system. When I am running it in windows it results following stack trace:

  File "build\bdist.win32\egg\mechanize\_mechanize.py", line 203, in open
    return self._mech_open(url, data, timeout=timeout)
  File "build\bdist.win32\egg\mechanize\_mechanize.py", line 230, in _mech_open
    response = UserAgentBase.open(self, request, data)
  File "build\bdist.win32\egg\mechanize\_opener.py", line 193, in open
    response = urlopen(self, req, data)
  File "build\bdist.win32\egg\mechanize\_urllib2_fork.py", line 344, in _open
    '_open', req)
  File "build\bdist.win32\egg\mechanize\_urllib2_fork.py", line 332, in _call_chain
    result = func(*args)
  File "build\bdist.win32\egg\mechanize\_urllib2_fork.py", line 1170, in https_open
    return self.do_open(conn_factory, req)
  File "build\bdist.win32\egg\mechanize\_urllib2_fork.py", line 1118, in do_open
    raise URLError(err)
URLError: <urlopen error [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond>
4
  • 1
    Is it a specific URL which causes it to throw this error? URLError looks like a timeout error. Use try..except to handle this error if it turns out not to be fatal. Commented May 17, 2012 at 7:44
  • Put the part of code, that makes request, here. Commented Mar 31, 2016 at 12:28
  • Are you using the same python and mechanize versions on all of the systems? Commented Mar 31, 2016 at 13:25
  • 1
    You might have more luck if you post a complete code snippet that consistently reproduces the problem. I'm with the other commenters, in that I'm guessing there's something else dodgy going on outside Mechanize. Admittedly, Windows forks differently than *nix systems, and maybe that's part of it, but it's almost certainly not the whole puzzle. Commented Apr 5, 2016 at 14:04

2 Answers 2

5
+25

I heavily doubt that the problem is connected to your system. To fix the problem, I would recommend:

  1. Check your mechanize version. Older versions might handle requests differently.
  2. Investigate set_handle_robots and addheaders. Issue might be connected to too many requests per IP. (I suspect that this is the real problem.)
  3. Check error handling. Like described in a comment above you should add proper error handling anyway.

If none of the described solutions above works, please provide the code which is causing the error.

Sign up to request clarification or add additional context in comments.

Comments

1

From the error I deduce that the server you're trying to connect to is not allowing your connection.

Try to use telnet to double check you can connect to the URL/IP:PORT you are requesting:

telnet <ip> <port>

PS: Just in case, don't use ping you check the connectivity as you're not testing the port.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.