File: gevent-get-input.py

package info (click to toggle)
prompt-toolkit 3.0.51-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,232 kB
  • sloc: python: 30,894; makefile: 151; sh: 6
file content (25 lines) | stat: -rwxr-xr-x 685 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python
"""
For testing: test to make sure that everything still works when gevent monkey
patches are applied.
"""

from gevent.monkey import patch_all

from prompt_toolkit.eventloop.defaults import create_event_loop
from prompt_toolkit.shortcuts import PromptSession

if __name__ == "__main__":
    # Apply patches.
    patch_all()

    # There were some issues in the past when the event loop had an input hook.
    def dummy_inputhook(*a):
        pass

    eventloop = create_event_loop(inputhook=dummy_inputhook)

    # Ask for input.
    session = PromptSession("Give me some input: ", loop=eventloop)
    answer = session.prompt()
    print(f"You said: {answer}")