Fixes: debbugs:19755
Thanks to Carlos Pita <carlosjosepita@gmail.com> for reporting
this and providing useful ideas.
* lisp/progmodes/python.el
(python-shell-completion-native-output-timeout): Increase value.
(python-shell-completion-native-try-output-timeout): New var.
(python-shell-completion-native-try): Use it.
(python-shell-completion-native-setup): New readline setup avoids
polluting current context, ensures output when no-completions are
available and includes output end marker.
(python-shell-completion-native-get-completions): Trigger with one
tab only. Call accept-process-output until output end is found or
python-shell-completion-native-output-timeout is exceeded.