docstr: Test that temporary socket/port is unreleased prior to invoking user map_fun.
docstr_tok: ["Test","that","temporary","socket\/port","is","unreleased","prior","to","invoking","user","map_fun","."]
code: def test_port_unreleased(self):
      """Test that temporary socket/port is unreleased prior to invoking user map_fun."""
  
      def _map_fun(args, ctx):
          import socket
  
          assert ctx.tmp_socket is not None
          reserved_port = ctx.tmp_socket.getsockname()[1]
  
          # socket bind to tmp port should fail
          try:
              my_sock = socket.socket(
                  socket.AF_INET, socket.SOCK_STREAM
              )
              my_sock.bind(("0.0.0.0", reserved_port))
              assert False, "should never hit this assert statement"
          except socket.error as e:
              print(e)
              assert True, "should raise an exception"
  
          ctx.release_port()
          assert ctx.tmp_socket is None
  
      cluster = TFCluster.run(
          self.sc,
          _map_fun,
          tf_args={},
          num_executors=self.num_workers,
          num_ps=0,
          input_mode=TFCluster.InputMode.TENSORFLOW,
          master_node="chief",
          release_port=False,
      )
      cluster.shutdown()
  
file_path: TensorFlowOnSpark/tests/test_TFCluster.py
imports: import unittest
  import test
  import time
  from tensorflowonspark import TFCluster, TFNode
label_desc: Use image node_id 8 for calling the TFClusterTest obj's underlying member method code with example usage: obj.test_port_unreleased() without return types