title: Pyspark: python worker failed to connect back/socketTimeOut
body: <p>I am very new to pyspark and still somewhat of a beginner with python. I'm taking an online course to better learn pyspark, but I cannot get the following code to run. I've tried both collect and take to see if i can test the initial result after parsing lines, but that doesn't seem to work. I have attached the error message provided by jupyter notebook on my local windows machine.</p>
  
  <pre><code>import findspark
  findspark.init()
  from pyspark import SparkConf, SparkContext
  
  conf = SparkConf().setMaster("local").setAppName("MinTemperatures")
  conf.set("spark.network.timeout", "600s")
  sc = SparkContext.getOrCreate()
  
  def parseLine(line):
      fields = line.split(',')
      stationID = fields[0]
      entryType = fields[2]
      temperature = fields[3]
      return (stationID, entryType, temperature)
  
  file="C:/sparkCourse/1800.csv"
  lines = sc.textFile(file)
  parsedLines = lines.map(parseLine)
  minTemps = parsedLines.filter(lambda x: "TMIN" in x[1])
  stationTemps = minTemps.map(lambda x: (x[0], x[2]))
  minTemps = stationTemps.reduceByKey(lambda x, y: min(x,y))
  
  lines.take(5)
  #results = minTemps.collect();
  
  #for result in results:
  #    print(result[0] + "\t{:.2f}F".format(result[1]))
  
  
  
  
  
  
  
  
      ---------------------------------------------------------------------------
      Py4JJavaError                             Traceback (most recent call last)
      &lt;ipython-input-4-6a97a8b6e79c&gt; in &lt;module&gt;
           21 minTemps = stationTemps.reduceByKey(lambda x, y: min(x,y))
           22 
      ---&gt; 23 lines.take(5)
           24 #results = minTemps.collect();
           25 
  
      C:\spark\python\pyspark\rdd.py in take(self, num)
         1358 
         1359             p = range(partsScanned, min(partsScanned + numPartsToTry, totalParts))
      -&gt; 1360             res = self.context.runJob(self, takeUpToNumLeft, p)
         1361 
         1362             items += res
  
      C:\spark\python\pyspark\context.py in runJob(self, rdd, partitionFunc, partitions, allowLocal)
         1049         # SparkContext#runJob.
         1050         mappedRDD = rdd.mapPartitions(partitionFunc)
      -&gt; 1051         sock_info = self._jvm.PythonRDD.runJob(self._jsc.sc(), mappedRDD._jrdd, partitions)
         1052         return list(_load_from_socket(sock_info, mappedRDD._jrdd_deserializer))
         1053 
  
      C:\spark\python\lib\py4j-0.10.7-src.zip\py4j\java_gateway.py in __call__(self, *args)
         1255         answer = self.gateway_client.send_command(command)
         1256         return_value = get_return_value(
      -&gt; 1257             answer, self.gateway_client, self.target_id, self.name)
         1258 
         1259         for temp_arg in temp_args:
  
      C:\spark\python\pyspark\sql\utils.py in deco(*a, **kw)
           61     def deco(*a, **kw):
           62         try:
      ---&gt; 63             return f(*a, **kw)
           64         except py4j.protocol.Py4JJavaError as e:
           65             s = e.java_exception.toString()
  
      C:\spark\python\lib\py4j-0.10.7-src.zip\py4j\protocol.py in get_return_value(answer, gateway_client, target_id, name)
          326                 raise Py4JJavaError(
          327                     "An error occurred while calling {0}{1}{2}.\n".
      --&gt; 328                     format(target_id, ".", name), value)
          329             else:
          330                 raise Py4JError(
  
      Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.runJob.
      : org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 1.0 failed 1 times, most recent failure: Lost task 0.0 in stage 1.0 (TID 1, localhost, executor driver): org.apache.spark.SparkException: Python worker failed to connect back.
          at org.apache.spark.api.python.PythonWorkerFactory.createSimpleWorker(PythonWorkerFactory.scala:170)
          at org.apache.spark.api.python.PythonWorkerFactory.create(PythonWorkerFactory.scala:97)
          at org.apache.spark.SparkEnv.createPythonWorker(SparkEnv.scala:117)
          at org.apache.spark.api.python.BasePythonRunner.compute(PythonRunner.scala:108)
          at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:65)
          at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:324)
          at org.apache.spark.rdd.RDD.iterator(RDD.scala:288)
          at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
          at org.apache.spark.scheduler.Task.run(Task.scala:121)
          at org.apache.spark.executor.Executor$TaskRunner$$anonfun$10.apply(Executor.scala:402)
          at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1360)
          at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:408)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          at java.lang.Thread.run(Unknown Source)
      Caused by: java.net.SocketTimeoutException: Accept timed out
          at java.net.DualStackPlainSocketImpl.waitForNewConnection(Native Method)
          at java.net.DualStackPlainSocketImpl.socketAccept(Unknown Source)
          at java.net.AbstractPlainSocketImpl.accept(Unknown Source)
          at java.net.PlainSocketImpl.accept(Unknown Source)
          at java.net.ServerSocket.implAccept(Unknown Source)
          at java.net.ServerSocket.accept(Unknown Source)
          at org.apache.spark.api.python.PythonWorkerFactory.createSimpleWorker(PythonWorkerFactory.scala:164)
          ... 14 more
  
      Driver stacktrace:
          at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1887)
          at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1875)
          at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1874)
          at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
          at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
          at org.apache.spark.scheduler.DAGScheduler.abortStage(DAGScheduler.scala:1874)
          at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:926)
          at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:926)
          at scala.Option.foreach(Option.scala:257)
          at org.apache.spark.scheduler.DAGScheduler.handleTaskSetFailed(DAGScheduler.scala:926)
          at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.doOnReceive(DAGScheduler.scala:2108)
          at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:2057)
          at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:2046)
          at org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:49)
          at org.apache.spark.scheduler.DAGScheduler.runJob(DAGScheduler.scala:737)
          at org.apache.spark.SparkContext.runJob(SparkContext.scala:2061)
          at org.apache.spark.SparkContext.runJob(SparkContext.scala:2082)
          at org.apache.spark.SparkContext.runJob(SparkContext.scala:2101)
          at org.apache.spark.api.python.PythonRDD$.runJob(PythonRDD.scala:153)
          at org.apache.spark.api.python.PythonRDD.runJob(PythonRDD.scala)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
          at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
          at py4j.Gateway.invoke(Gateway.java:282)
          at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
          at py4j.commands.CallCommand.execute(CallCommand.java:79)
          at py4j.GatewayConnection.run(GatewayConnection.java:238)
          at java.lang.Thread.run(Unknown Source)
      Caused by: org.apache.spark.SparkException: Python worker failed to connect back.
          at org.apache.spark.api.python.PythonWorkerFactory.createSimpleWorker(PythonWorkerFactory.scala:170)
          at org.apache.spark.api.python.PythonWorkerFactory.create(PythonWorkerFactory.scala:97)
          at org.apache.spark.SparkEnv.createPythonWorker(SparkEnv.scala:117)
          at org.apache.spark.api.python.BasePythonRunner.compute(PythonRunner.scala:108)
          at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:65)
          at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:324)
          at org.apache.spark.rdd.RDD.iterator(RDD.scala:288)
          at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
          at org.apache.spark.scheduler.Task.run(Task.scala:121)
          at org.apache.spark.executor.Executor$TaskRunner$$anonfun$10.apply(Executor.scala:402)
          at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1360)
          at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:408)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          ... 1 more
      Caused by: java.net.SocketTimeoutException: Accept timed out
          at java.net.DualStackPlainSocketImpl.waitForNewConnection(Native Method)
          at java.net.DualStackPlainSocketImpl.socketAccept(Unknown Source)
          at java.net.AbstractPlainSocketImpl.accept(Unknown Source)
          at java.net.PlainSocketImpl.accept(Unknown Source)
          at java.net.ServerSocket.implAccept(Unknown Source)
          at java.net.ServerSocket.accept(Unknown Source)
          at org.apache.spark.api.python.PythonWorkerFactory.createSimpleWorker(PythonWorkerFactory.scala:164)
          ... 14 more
  </code></pre>