def METHOD_NAME(self, ws):
    thread = event = None
    if ws.ping_interval:
        event = threading.Event()
        thread = threading.Thread(target=self._ping, args=(ws, event))
        thread.start()
    try:
        return fn(self, ws)
    finally:
        if thread and thread.isAlive():
            event.set()
            thread.join()