hologram-io / hologram-python

Hologram device-side Python SDK - Send messages to the cloud in just 3 lines of code!
https://hologram.io/
MIT License
89 stars 47 forks source link

Disconnecting from a PPP session that was started in a different script fails #30

Closed DomAmato closed 4 years ago

DomAmato commented 4 years ago

Describe the problem

A script tries to disconnect when a PPP session was started and not closed in a separate script. It fails to tear down that PPP session

2020-04-21 20:33:43,414 [INFO] Hologram.Network.Network (2670): Disconnecting from cell network
2020-04-21 20:33:43,415 [INFO] Hologram.Network.Network (2670): Failed to disconnect from cell network
2020-04-21 20:33:43,416 [INFO] Hologram.Network.Network (2670): Connecting to cell network with timeout of 200 seconds
2020-04-21 20:33:43,514 [INFO] Hologram.Network.Modem.ModemMode.ModemMode (2670): Checking for existing PPP sessions
2020-04-21 20:33:43,565 [INFO] Hologram.Network.Modem.ModemMode.ModemMode (2670): Found existing PPP session on pid: 2604
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/pi/ftp/hologram/__main__.py", line 32, in <module>
    pinger.run()
  File "/home/pi/ftp/hologram/pinger.py", line 51, in run
    self.hologram.network.connect()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Cellular.py", line 67, in connect
    success = self.modem.connect(timeout = timeout)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Nova_U201.py", line 36, in connect
    success = super().connect(timeout)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/Modem.py", line 97, in connect
    return self._mode.connect(timeout = timeout)
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/ModemMode/PPP.py", line 43, in connect
    self.__enforce_no_existing_ppp_session()
  File "/usr/local/lib/python3.7/dist-packages/Hologram/Network/Modem/ModemMode/PPP.py", line 72, in __enforce_no_existing_ppp_session
    % pid_list)
Exceptions.HologramError.PPPError: Existing PPP session(s) are established by pid(s) [2604]. Please close/kill these processes first

Expected behavior

Calling disconnect should stop other PPP sessions that are open regardless of what script started them.

Actual behavior

It fails to disconnect

Steps to reproduce the behavior

have 2 python scripts, one that starts a PPP session and another the disconnects. Run 1 than the other. It should fail

System information