Skip to content

Commit

Permalink
allowed master and outstation to shutdown gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
kefeimo committed Oct 30, 2022
1 parent d1ffdf9 commit 0495354
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions reset_dnp3_submodule.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Note: deprecated
git rm --cached deps/dnp3
rm -rf .git/modules/deps/dnp3
rm -rf deps/dnp3
Expand Down
1 change: 1 addition & 0 deletions reset_pybind11_submodule.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Note: deprecated
git rm --cached deps/pybind11
rm -rf .git/modules/deps/pybind11
rm -rf deps/pybind11
Expand Down
12 changes: 12 additions & 0 deletions src/dnp3_python/dnp3station/master_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,15 @@ def shutdown(self):
del self.master
del self.channel
del self.manager

# del self.slow_scan
# del self.fast_scan
# self.master.Shutdown()
# self.channel.Shutdown()
# self.manager.Shutdown()

def __del__(self):
try:
self.shutdown()
except AttributeError:
pass
10 changes: 8 additions & 2 deletions src/dnp3_python/dnp3station/outstation_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ def shutdown(self):
"""
time.sleep(2) # Note: hard-coded sleep to avoid hanging process
_outstation = self.get_outstation()
# _outstation.Shutdown()
del _outstation
_outstation.Shutdown()
# del _outstation
self.channel.Shutdown()

# self.manager.Shutdown()
Expand Down Expand Up @@ -305,6 +305,12 @@ def apply_update(cls,
update = asiodnp3.UpdateBuilder().Update(measurement, index).Build()
cls.get_outstation().Apply(update)

def __del__(self):
try:
self.shutdown()
except Exception:
pass


class OutstationCommandHandler(opendnp3.ICommandHandler):
"""
Expand Down

0 comments on commit 0495354

Please sign in to comment.