akshaykmr / hogwatch

[not maintained] find out what's hogging your internet connection.
MIT License
1.23k stars 36 forks source link

nethog processes left running on exit on Ubuntu 16.04 #7

Closed pmontrasio closed 8 years ago

pmontrasio commented 8 years ago

After clicking the x button to close the program two nethog processes are left running.

root 2123 13757 0 10:38 pts/1 00:00:00 nethogs -d 1 -v 0 -t root 2124 13757 0 10:38 pts/1 00:00:00 nethogs -d 1 -v 1 -t

Process 13757 is

me   13757 13660  0 apr29 ?        00:00:00 /sbin/upstart --user

If I run hogwatch again I get

$ sudo /home/me/.local/bin/hogwatch 
/home/me/.local/lib/python2.7/site-packages/application/server/static/
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/me/.local/lib/python2.7/site-packages/application/server/web_service.py", line 117, in app_server
    server.serve_forever()
  File "/home/me/.local/lib/python2.7/site-packages/gevent/baseserver.py", line 347, in serve_forever
    self.start()
  File "/home/me/.local/lib/python2.7/site-packages/gevent/baseserver.py", line 291, in start
    self.init_socket()
  File "/home/me/.local/lib/python2.7/site-packages/gevent/pywsgi.py", line 1222, in init_socket
    StreamServer.init_socket(self)
  File "/home/me/.local/lib/python2.7/site-packages/gevent/server.py", line 80, in init_socket
    self.socket = self.get_listener(self.address, self.backlog, self.family)
  File "/home/me/.local/lib/python2.7/site-packages/gevent/server.py", line 91, in get_listener
    return _tcp_listener(address, backlog=backlog, reuse_addr=self.reuse_addr, family=family)
  File "/home/me/.local/lib/python2.7/site-packages/gevent/server.py", line 177, in _tcp_listener
    sock.bind(address)
  File "<string>", line 1, in bind
error: [Errno 98] Address already in use: ('0.0.0.0', 6432)

and hogwatch's window is blank. I have to manually kill those two processes to make it work again.

Sometimes I also get Segmentation fault (core dumped) in the console I run hogwatch from, but the two processes are left running even when there is no core dump.

akshaykmr commented 8 years ago

I have pushed a fix for server mode, all threads should be taken care of on exiting the server.

Still working on a fix for window(webview) mode.

    window_title='hogwatch'

    server=Thread(
        target=app_server
    )
    server.setDaemon(True)
    server.start()

    webview.create_window(
        window_title,
        url,
        resizable=True,
        width=400,
        height=600,
        min_size=(320, 300)
    )

In hogwatch init script, I start the webserver in daemon mode, which means it should exit when all the non-daemon threads have finished but that doesn't happen.

PS: the webview.create_window method is a blocking one. continuing on hitting the 'x' button. pywebview for reference

akshaykmr commented 8 years ago

fixed.