Ping entries to a directory in a thread.
964566
def run(self):
        
        logger = getLogger('zinnia.ping.directory')
        socket.setdefaulttimeout(self.timeout)
        for entry in self.entries:
            reply = self.ping_entry(entry)
            self.results.append(reply)
            logger.info('%s : %s', self.server_name, reply['message'])
        socket.setdefaulttimeout(None)
1043712
def ping(self):
        
        start = time.time()
        self._conn.ping()
        return (time.time() - start)
523596
def ping(self, remote):
        """"""
        try:
            self.proxies["%s-%s" % (self._interface_id, remote)].ping("%s-%s" % (self._interface_id, remote))
        except Exception as err:
            LOG.warning("ServerThread.ping: Exception: %s" % str(err))
152401
def on_open(self, ws):
        """"""
        def keep_alive(interval):
            while True:
                time.sleep(interval)
                self.ping()

        start_new_thread(keep_alive, (self.keep_alive_interval, ))
364621
public static void ping(String driver, String url, String user, String password) {
		try {
			Class.forName(driver);
			Connection connection = DriverManager.getConnection(url, user, password);
			connection.close();
		} catch (Exception e) {
			JKExceptionUtil.handle(e);
		}
	}
783956
def thread_info(self):
        """"""
        tid = threading.current_thread().name
        if tid == 'MainThread':
            tid = 'Main'
        current = fibers.current()
        fid = getattr(current, 'name') if current.parent else 'Root'
        return '{}/{}'.format(tid, fid)
890186
async def poll(self):
        """"""
        try:
            packets = [await asyncio.wait_for(self.queue.get(),
                                              self.server.ping_timeout)]
            self.queue.task_done()
        except (asyncio.TimeoutError, asyncio.CancelledError):
            raise exceptions.QueueEmpty()
        if packets == [None]:
            return []
        try:
            packets.append(self.queue.get_nowait())
            self.queue.task_done()
        except asyncio.QueueEmpty:
            pass
        return packets
721584
def _threaded(self, *args, **kwargs):
        """"""

        for target in self.targets:
            result = target(*args, **kwargs)
            self.queue.put(result)
1157129
def run_locally(self):
        """"""
        self.thread = threading.Thread(target=self.execute_locally)
        self.thread.daemon = True # So that they die when we die
        self.thread.start()
937304
public void join() {
    try {
      if (server != null) server.join();
      if (triggerThread != null) triggerThread.join();
      if (fileFixerThread != null) fileFixerThread.join();
    } catch (InterruptedException ie) {
      // do nothing
    }
  }
1317149
def select_directory(self):
        """"""
        self.redirect_stdio.emit(False)
        directory = getexistingdirectory(self.main, _(""),
                                         getcwd_or_home())
        if directory:
            self.chdir(directory)
        self.redirect_stdio.emit(True)
343088
def _await_socket(self, timeout):
    """"""
    with safe_open(self._ng_stdout, 'r') as ng_stdout:
      start_time = time.time()
      accumulated_stdout = ''
      while 1:
        # TODO: share the decreasing timeout logic here with NailgunProtocol.iter_chunks() by adding
        # a method to pants.util.contextutil!
        remaining_time = time.time() - (start_time + timeout)
        if remaining_time > 0:
          stderr = read_file(self._ng_stderr, binary_mode=True)
          raise self.InitialNailgunConnectTimedOut(
            timeout=timeout,
            stdout=accumulated_stdout,
            stderr=stderr,
          )

        readable, _, _ = select.select([ng_stdout], [], [], (-1 * remaining_time))
        if readable:
          line = ng_stdout.readline()                          # TODO: address deadlock risk here.
          try:
            return self._NG_PORT_REGEX.match(line).group(1)
          except AttributeError:
            pass
          accumulated_stdout += line
1132409
def push(self, dir):
        
        self.stack.append(os.getcwd())
        os.chdir(dir or os.getcwd())
1066694
def threaded(
    name: typing.Callable[..., typing.Any], daemon: bool = False, started: bool = False
) -> typing.Callable[..., threading.Thread]:
    """"""
830768
def _ping(self) -> bool:
        """"""
        assert self.socket is not None
        resp = None
        try:
            self.socket.sendall(b"PINGPING")
            resp = self.socket.recv(8)
        except Exception:
            pass
        return resp == b"PONGPONG"
657237
def write_ping(self, data: bytes) -> None:
        """"""
        assert isinstance(data, bytes)
        self._write_frame(True, 0x9, data)
374952
private String write(String logDir) throws IOException, ExecutionException, InterruptedException {
        final File file = new File(logDir, "trace_" + System.currentTimeMillis() + ".json.gz");
        if (file.exists()) {
            throw new IOException("Trace file " + file.getAbsolutePath() + " already exists");
        }
        if (!file.getParentFile().canWrite() || !file.getParentFile().canExecute()) {
            throw new IOException("Trace file " + file.getAbsolutePath() + " is not writable");
        }

        SettableFuture<Future<?>> f = SettableFuture.create();
        m_work.offer(() -> f.set(dumpEvents(file)));
        final Future<?> writeFuture = f.get();
        if (writeFuture != null) {
            writeFuture.get(); // Wait for the write to finish without blocking new events
            return file.getAbsolutePath();
        } else {
            // A write is already in progress, ignore this request
            return null;
        }
    }