def ensure_port_cleanup(bound_addresses, maxtries=30, sleeptime=2):
 atexit.register(_cleanup_ports, bound_addresses, maxtries=maxtries, sleeptime=sleeptime)

def ensure_port_cleanup ( bound_addresses , maxtries = 30 , sleeptime = 2 ) : atexit . register ( _cleanup_ports , bound_addresses , maxtries = maxtries , sleeptime = sleeptime )
this makes sure any open ports are closed .