YoRyan / nuxhash

A NiceHash cryptocurrency mining client for Linux.
GNU General Public License v3.0
264 stars 164 forks source link

crash when internet is out #20

Closed mysticaltech closed 6 years ago

mysticaltech commented 6 years ago

Hey man, it crashes when the internet drops for a few minutes. Anyway to fix this? Maybe set some kind of incremental backoff retry in the code?

 % urlencode(get_data), timeout=TIMEOUT) as request:
  File "/home/gold/anaconda3/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/home/gold/anaconda3/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/home/gold/anaconda3/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/home/gold/anaconda3/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/home/gold/anaconda3/lib/python3.6/urllib/request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/home/gold/anaconda3/lib/python3.6/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gold/anaconda3/bin/nuxhashd", line 11, in <module>
    sys.exit(nuxhashd())
  File "/home/gold/anaconda3/lib/python3.6/site-packages/nuxhash/__init__.py", line 3, in nuxhashd
    main()
  File "/home/gold/anaconda3/lib/python3.6/site-packages/nuxhash/daemon.py", line 108, in main
    session.run()
  File "/home/gold/anaconda3/lib/python3.6/site-packages/nuxhash/daemon.py", line 267, in run
    self._scheduler.run()
  File "/home/gold/anaconda3/lib/python3.6/sched.py", line 154, in run
    action(*argument, **kwargs)
  File "/home/gold/anaconda3/lib/python3.6/site-packages/nuxhash/daemon.py", line 279, in _switch_algos
    except (os.ConnectionError, socket.error,
AttributeError: module 'os' has no attribute 'ConnectionError'
2018-11-14 00:01:47,856 CRITICAL: Crash! Killing all miners.
Killed
YoRyan commented 6 years ago

Try pulling the latest master. I was missing some exceptions in the handler for these sort of conditions.

mysticaltech commented 6 years ago

Thanks Ryan, will do!

mysticaltech commented 6 years ago

Ryan, I reinstalled the latest version from master but when my wifi went out for 1 minute, it crashed again, if you could somehow make it more robust would be great!

2018-11-18 03:41:45,729 DEBUG: [03:41:45][0x00007fafa658f780][info] net | x16r | Share #244 accepted
2018-11-18 03:42:07,836 WARNING: NiceHash stats: <urlopen error [Errno -2] Name or service not known>
Traceback (most recent call last):
  File "/usr/bin/nuxhashd", line 11, in <module>
    load_entry_point('nuxhash==1.0.0b2', 'console_scripts', 'nuxhashd')()
  File "/usr/lib/python3.6/site-packages/nuxhash/__init__.py", line 3, in nuxhashd
    main()
  File "/usr/lib/python3.6/site-packages/nuxhash/daemon.py", line 108, in main
    session.run()
  File "/usr/lib/python3.6/site-packages/nuxhash/daemon.py", line 266, in run
    self._scheduler.run()
  File "/usr/lib64/python3.6/sched.py", line 154, in run
    action(*argument, **kwargs)
  File "/usr/lib/python3.6/site-packages/nuxhash/daemon.py", line 297, in _switch_algos
    for device in self._devices}
  File "/usr/lib/python3.6/site-packages/nuxhash/daemon.py", line 297, in <dictcomp>
    for device in self._devices}
  File "/usr/lib/python3.6/site-packages/nuxhash/daemon.py", line 296, in <dictcomp>
    for algorithm in self._algorithms}
  File "/usr/lib/python3.6/site-packages/nuxhash/daemon.py", line 292, in revenue
    for i in range(len(algorithm.algorithms))])
  File "/usr/lib/python3.6/site-packages/nuxhash/daemon.py", line 292, in <listcomp>
    for i in range(len(algorithm.algorithms))])
NameError: free variable 'payrates' referenced before assignment in enclosing scope
2018-11-18 03:42:07,843 CRITICAL: Crash! Killing all miners.
YoRyan commented 6 years ago

Fixed! Apologies for the all of the bugs, I restructured a lot of this code and didn't quite anticipate all of the effects.

mysticaltech commented 6 years ago

Thanks man! Keep up the good work.