Skip to content

Commit f712084

Browse files
committed
Merge branch 'master' of https://github.com/Kisensum/pydnp3
2 parents 56876bd + bcd40b3 commit f712084

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/test_hang.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# MAKE SURE TO RUN OUTSTATION FOR TESTING
2+
3+
from pydnp3 import asiodnp3, asiopal, opendnp3, openpal
4+
5+
import time
6+
7+
FILTERS = opendnp3.levels.NORMAL | opendnp3.levels.ALL_COMMS
8+
HOST = "127.0.0.1"
9+
LOCAL = "0.0.0.0"
10+
PORT = 20000
11+
12+
13+
14+
def run_master(hang=False):
15+
"""Demonstrate hanging when channel and master are not deleted prior to manager.Shutdown()
16+
"""
17+
logger = asiodnp3.ConsoleLogger().Create()
18+
manager = asiodnp3.DNP3Manager(1, asiodnp3.ConsoleLogger().Create())
19+
#printing_channel_listener = asiodnp3.PrintingChannelListener().Create()
20+
channel = manager.AddTCPClient("tcpclient",
21+
FILTERS,
22+
asiopal.ChannelRetry(),
23+
HOST,
24+
LOCAL,
25+
PORT,
26+
asiodnp3.PrintingChannelListener().Create())
27+
stack_config = asiodnp3.MasterStackConfig()
28+
stack_config.master.responseTimeout = openpal.TimeDuration().Seconds(2)
29+
stack_config.link.RemoteAddr = 10
30+
soe_handler = asiodnp3.PrintingSOEHandler().Create()
31+
default_master_app = asiodnp3.DefaultMasterApplication().Create()
32+
master = channel.AddMaster("master",
33+
soe_handler,
34+
default_master_app,
35+
stack_config)
36+
master.Enable()
37+
time.sleep(2)
38+
if not hang:
39+
#del logger
40+
#del printing_channel_listener
41+
del channel
42+
#del stack_config
43+
#del soe_handler
44+
#del default_master_app
45+
del master
46+
print("Shutdown, Hang = {}".format(hang))
47+
manager.Shutdown()
48+
49+
# run_master(hang=False)
50+
# run_master(hang=False)
51+
# #run_master(hang=True)
52+

0 commit comments

Comments
 (0)