rachmadaniHaryono / we-get

:icecream: Command-line tool for searching torrents.
MIT License
153 stars 26 forks source link

Catch timeout and proceed to next target #12

Open danDanV1 opened 5 years ago

danDanV1 commented 5 years ago

If the first target times out, it errors.

Traceback (most recent call last):ay' ...
  File "/usr/bin/we-get", line 11, in <module>
    load_entry_point('we-get==1.1.0', 'console_scripts', 'we-get')()
  File "/usr/lib/python3.6/site-packages/we_get/__init__.py", line 14, in main
    we_get.start()
  File "/usr/lib/python3.6/site-packages/we_get/core/we_get.py", line 237, in start
    sel.run()
  File "/usr/lib/python3.6/site-packages/we_get/core/we_get.py", line 158, in run
    items = run.main(self.pargs)
  File "/usr/lib/python3.6/site-packages/we_get/modules/the_pirate_bay.py", line 78, in main
    return run.search()
  File "/usr/lib/python3.6/site-packages/we_get/modules/the_pirate_bay.py", line 62, in search
    data = self.module.http_get_request(url)
  File "/usr/lib/python3.6/site-packages/we_get/core/module.py", line 24, in http_get_request
    return opener.open(url).read().decode()
  File "/usr/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 522: Origin Connection Time-out

Could this be caught, logged to console, then continue to the next target?

rachmadaniHaryono commented 5 years ago

hi @edeis53 , can you check if #13 work for you?