code: def ensure_port_cleanup(bound_addresses, maxtries=30, sleeptime=2):
      
      atexit.register(_cleanup_ports, bound_addresses, maxtries=maxtries,
                      sleeptime=sleeptime)
docs: This makes sure any open ports are closed.
  
      Does this by connecting to them until they give connection
      refused.  Servers should call like::
  
          import paste.script
          ensure_port_cleanup([80, 443])