Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Euler download.py crashes on large batch #1

Open
jayvdb opened this issue May 16, 2016 · 1 comment
Open

Project Euler download.py crashes on large batch #1

jayvdb opened this issue May 16, 2016 · 1 comment

Comments

@jayvdb
Copy link
Contributor

jayvdb commented May 16, 2016

When doing a large batch download, e.g. starting from 1, download.py crashes with URLError due to Connection timed out.

Problem 232
Downloading...
Traceback (most recent call last):
  File "download.py", line 98, in <module>
    main()
  File "download.py", line 92, in main
    downloaded = save_problem(problem_num)
  File "download.py", line 68, in save_problem
    soup = download(url)
  File "download.py", line 57, in download
    data = browser.open(url).get_data()
  File "/usr/lib/python2.7/site-packages/mechanize/_mechanize.py", line 203, in open
    return self._mech_open(url, data, timeout=timeout)
  File "/usr/lib/python2.7/site-packages/mechanize/_mechanize.py", line 230, in _mech_open
    response = UserAgentBase.open(self, request, data)
  File "/usr/lib/python2.7/site-packages/mechanize/_opener.py", line 193, in open
    response = urlopen(self, req, data)
  File "/usr/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 344, in _open
    '_open', req)
  File "/usr/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 332, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 1142, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/site-packages/mechanize/_urllib2_fork.py", line 1118, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 110] Connection timed out>
@jontsai
Copy link
Member

jontsai commented May 18, 2016

Yeah, probably not much you can do here. Do a smaller batch or increase the sleep timeout between each download.

If we make a fix here, PE can always change settings on their end. Maybe the best fix for this script is to add some comments about what a user can do to mitigate issues like this happening.

jontsai added a commit that referenced this issue Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants