cn-uofbasel / PiCN

PiCN: Python ICN and NFN by University of Basel
BSD 3-Clause "New" or "Revised" License
18 stars 14 forks source link

Management command 'shutdown' causes exception #8

Open cmarxer opened 6 years ago

cmarxer commented 6 years ago

Sending 'shutdown' is not handled properly (sent with Mgmt.py):

2018-01-31 16:36:17,998 - MgmtSys    INFO:   Shutdown
Process Process-6:
Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/home/claudio/software/PiCN/PiCN/Mgmt/Mgmt.py", line 157, in _run
    self.mgmt(mgmt_sock)
  File "/home/claudio/software/PiCN/PiCN/Mgmt/Mgmt.py", line 79, in mgmt
    self.shutdown()
  File "/home/claudio/software/PiCN/PiCN/ProgramLibs/ICNForwarder/ICNForwarder.py", line 86, in stop_forwarder
    self.mgmt.stop_process()
  File "/home/claudio/software/PiCN/PiCN/Mgmt/Mgmt.py", line 165, in stop_process
    self.process.terminate()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 116, in terminate
    self._popen.terminate()
AttributeError: 'NoneType' object has no attribute 'terminate'
cmarxer commented 6 years ago

Also termination with Ctrl+C should be handled properly:

~> picn-relay 
2018-02-01 14:52:35,320 - ICNForwarder   INFO:   Starting a CCN Forwarder...
2018-02-01 14:52:35,320 - ICNForwarder   INFO:   UDP Port:       9000
2018-02-01 14:52:35,320 - ICNForwarder   INFO:   Log Level:      info
2018-02-01 14:52:35,320 - ICNForwarder   INFO:   Packet Format:  ndntlv
^CTraceback (most recent call last):
  File "/home/claudio/software/PiCN/PiCN/Executable/ICNForwarder.py", line 47, in <module>
    main(args)
  File "/home/claudio/software/PiCN/PiCN/Executable/ICNForwarder.py", line 38, in main
    forwarder.linklayer.process.join()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 124, in join
    res = self._popen.wait(timeout)
  File "/usr/lib/python3.6/multiprocessing/popen_fork.py", line 57, in wait
    return self.poll(os.WNOHANG if timeout == 0.0 else 0)
  File "/usr/lib/python3.6/multiprocessing/popen_fork.py", line 35, in poll
    pid, sts = os.waitpid(self.pid, flag)
KeyboardInterrupt
Process Process-6:
Process Process-4:
Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/home/claudio/software/PiCN/PiCN/Processes/LayerProcess.py", line 118, in _run
    self._run_poll(from_lower, from_higher, to_lower, to_higher)
  File "/home/claudio/software/PiCN/PiCN/Processes/LayerProcess.py", line 76, in _run_poll
    ready_vars = poller.poll()
KeyboardInterrupt
Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/home/claudio/software/PiCN/PiCN/Mgmt/Mgmt.py", line 156, in _run
    ready_vars = poller.poll()
KeyboardInterrupt
Process Process-3:
Process Process-5:
Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()