rbonghi / jetson_stats

📊 Simple package for monitoring and control your NVIDIA Jetson [Orin, Xavier, Nano, TX] series
https://rnext.it/jetson_stats
GNU Affero General Public License v3.0
2.17k stars 264 forks source link

Unable to reinstance jtop after service restart #261

Closed jabesq closed 1 year ago

jabesq commented 2 years ago

Describe the bug If the jetson_stats.service restart, then it is impossible to recreate a new instance of jtop object in python apps, except by restarting everythin

To Reproduce Steps to reproduce the behavior:

  1. in python console, open a jtop instance
    >>> with jtop() as jetson:
     ...
  2. Restart jetson_stats.service
  3. In the same python console, open a new jtop instance
    >>> with jtop() as jetson:
     ...
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "PATH/lib/python3.9/site-packages/jtop/jtop.py", line 1081, in __enter__
    self.start()
    File "PATH/lib/python3.9/site-packages/jtop/jtop.py", line 956, in start
    init = self._get_configuration()
    File "PATH/lib/python3.9/site-packages/jtop/jtop.py", line 905, in _get_configuration
    self._controller.put({'interval': self._interval})
    File "<string>", line 2, in put
    File "PATH/lib/python3.9/multiprocessing/managers.py", line 809, in _callmethod
    conn.send((self._id, methodname, args, kwds))
    File "/PATH/lib/python3.9/multiprocessing/connection.py", line 211, in send
    self._send_bytes(_ForkingPickler.dumps(obj))
    File "PATH/python3.9/multiprocessing/connection.py", line 416, in _send_bytes
    self._send(header + buf)
    File PATH/lib/python3.9/multiprocessing/connection.py", line 373, in _send
    n = write(self._handle, buf)
    BrokenPipeError: [Errno 32] Broken pipe

Expected behavior Ability to continue jtop API after service restart

Additional context Add any other context about the problem here.

Board

Jetpack

Jetson-Stats

rbonghi commented 1 year ago

Hi @jabesq ,

I know I reply really late to this issue. As you notice, if you restart the service, you need to restart all jtop clients as well. I didn't notice any workaround to fix this bug.

jtop use the SyncManager to communicate https://docs.python.org/3.9/library/multiprocessing.html#multiprocessing.managers.SyncManager

When the service crash crash also the pipe and all terminals crash. IF you know a workaround to fix it, let me know. I close this issue, but feel free to reopen it