def _on_input_timeout(self, buff: Buffer) -> None:
        """
        When there is no input activity,
        in another thread, get the signature of the current code.
        """

        def get_signatures_in_executor(document: Document) -> list[Signature]:
            # First, get signatures from Jedi. If we didn't found any and if
            # "dictionary completion" (eval-based completion) is enabled, then
            # get signatures using eval.
            signatures = get_signatures_using_jedi(
                document, self.get_locals(), self.get_globals()
            )
            if not signatures and self.enable_dictionary_completion:
                signatures = get_signatures_using_eval(
                    document, self.get_locals(), self.get_globals()
                )

            return signatures

        app = self.app

        async def on_timeout_task() -> None:
            loop = get_running_loop()

            # Never run multiple get-signature threads.
            if self._get_signatures_thread_running:
                return
            self._get_signatures_thread_running = True

            try:
                while True:
                    document = buff.document
                    signatures = await loop.run_in_executor(
                        None, get_signatures_in_executor, document
                    )

                    # If the text didn't change in the meantime, take these
                    # signatures. Otherwise, try again.
                    if buff.text == document.text:
                        break
            finally:
                self._get_signatures_thread_running = False

            # Set signatures and redraw.
            self.signatures = signatures

            # Set docstring in docstring buffer.
            if signatures:
                self.docstring_buffer.reset(
                    document=Document(signatures[0].docstring, cursor_position=0)
                )
            else:
                self.docstring_buffer.reset()

            app.invalidate()

        if app.is_running:
            app.create_background_task(on_timeout_task())

        When there is no input activity,
        in another thread, get the signature of the current code.
        
src/ptpython/python_input.py