def _create_auto_suggest_function(self, buffer):
        suggest_thread_running = [False]  # By ref.

        def async_suggestor():
            document = buffer.document

            # Don't start two threads at the same time.
            if suggest_thread_running[0]:
                return

            # Don't suggest when we already have a suggestion.
            if buffer.suggestion or not buffer.auto_suggest:
                return

            # Otherwise, get completions in other thread.
            suggest_thread_running[0] = True

            def run():
                suggestion = buffer.auto_suggest.get_suggestion(self, buffer, document)
                suggest_thread_running[0] = False

                def callback():
                    # Set suggestion only if the text was not yet changed.
                    if buffer.text == document.text and \
                            buffer.cursor_position == document.cursor_position:

                        # Set suggestion and redraw interface.
                        buffer.suggestion = suggestion
                        self.invalidate()
                    else:
                        # Otherwise, restart thread.
                        async_suggestor()

                if self.eventloop:
                    self.eventloop.call_from_executor(callback)

            self.eventloop.run_in_executor(run)
        return async_suggestor
Returns the shuffled list.
dataset/ETHPy150Open jonathanslenders/python-prompt-toolkit/prompt_toolkit/interface.py/CommandLineInterface._create_auto_suggest_function--crossover with--dataset/ETHPy150Open dokterbob/satchmo/satchmo/apps/satchmo_store/shop/templatetags/satchmo_util.py/shuffle