57764c143badff6a194a83a818b8f95bb8df7625,src/python/twitter/pants/tasks/nailgun_task.py,NailgunTask,_await_nailgun_server,#NailgunTask#Any#,220

Before Change


    max_socket_connect_attempts = 10
    start = time.time()

    endpoint = self._get_nailgun_endpoint()
    while endpoint is None:
      if time.time() - start > nailgun_timeout_seconds:
        raise NailgunError("Failed to read ng output after %s seconds" % nailgun_timeout_seconds)
      time.sleep(0.1)
      endpoint = self._get_nailgun_endpoint()

    port = endpoint[1]
    nailgun = self._create_ngclient(port, workunit)
    log.debug("Detected ng server up on port %d" % port)

After Change


  def _await_nailgun_server(self, workunit):
    nailgun_timeout_seconds = 5
    max_socket_connect_attempts = 10
    nailgun = None
    port_parse_start = time.time()
    with _safe_open(self._ng_out, "r") as ng_out:
      while not nailgun:
        started = ng_out.readline()
        if started:
          port = self._parse_nailgun_port(started)
          with open(self._pidfile, "a") as pidfile:
            pidfile.write(":%d\n" % port)
          nailgun = self._create_ngclient(port, workunit)
          log.debug("Detected ng server up on port %d" % port)
        elif time.time() - port_parse_start > nailgun_timeout_seconds:
          raise NailgunError("Failed to read ng output after %s seconds" % nailgun_timeout_seconds)

    attempt = 0
    while nailgun:
      sock = nailgun.try_connect()
      if sock:
        sock.close()
        log.info("Connected to ng server pid: %d @ port: %d" % self._get_nailgun_endpoint())
        return nailgun
      elif attempt > max_socket_connect_attempts:
        raise NailgunError("Failed to connect to ng output after %d connect attempts"
                            % max_socket_connect_attempts)
      attempt += 1
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 18

Instances


Project Name: pantsbuild/pants
Commit Name: 57764c143badff6a194a83a818b8f95bb8df7625
Time: 2013-10-04
Author: john@foursquare.com
File Name: src/python/twitter/pants/tasks/nailgun_task.py
Class Name: NailgunTask
Method Name: _await_nailgun_server


Project Name: pantsbuild/pants
Commit Name: 7dcc1b532d21e47c98ba2422cab7d48360149f89
Time: 2013-10-06
Author: benjyw@gmail.com
File Name: src/python/twitter/pants/tasks/nailgun_task.py
Class Name: NailgunTask
Method Name: _await_nailgun_server


Project Name: pantsbuild/pants
Commit Name: 6101d42a47f4dca09a862090f7665bf83373f9d8
Time: 2013-07-29
Author: benjy@foursquare.com
File Name: src/python/twitter/pants/tasks/nailgun_task.py
Class Name: NailgunTask
Method Name: _await_nailgun_server