Fake EOF?
See original GitHub issueIs there a way for an application to signal to prompt_toolkit
that it should pretend an EOF has happened (typically making the application exit)? Something like this works with readline
but not with prompt_toolkit
:
In [1]: import os; f = open(os.devnull); os.dup2(f.fileno(), 0)
In [2]:
Traceback (most recent call last):
File "/usr/local/src/sage-config/local/bin/ipython", line 5, in <module>
start_ipython()
File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/IPython/__init__.py", line 119, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/traitlets/config/application.py", line 596, in launch_instance
app.start()
File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 348, in start
self.shell.mainloop()
File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/IPython/terminal/interactiveshell.py", line 402, in mainloop
self.interact()
File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/IPython/terminal/interactiveshell.py", line 385, in interact
code = self.prompt_for_code()
File "/usr/local/src/sage-config/local/lib/python2.7/site-packages/IPython/terminal/interactiveshell.py", line 321, in prompt_for_code
pre_run=self.pre_prompt, reset_current_buffer=True)
File "build/bdist.linux-x86_64/egg/prompt_toolkit/interface.py", line 385, in run
with self.input.raw_mode():
File "build/bdist.linux-x86_64/egg/prompt_toolkit/input.py", line 69, in raw_mode
return raw_mode(self.stdin.fileno())
File "build/bdist.linux-x86_64/egg/prompt_toolkit/terminal/vt100_input.py", line 409, in __init__
self.attrs_before = termios.tcgetattr(fileno)
error: (25, 'Inappropriate ioctl for device')
My use case is a signal handler forcing the application to exit gracefully.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to continue reading file when encountering fake EOF?
I try to read a file use Python. Notepad show that there are 200 lines. f = open('record.txt', 'r') for line in f.readlines():...
Read more >A fake EOF is reached by pressing continuously the key to display ...
A fake EOF is reached by pressing continuously the key to display the next frame from the H.264 videos from the M2TS, MTS,...
Read more >Handling end-of-file (eof) correctly
The eof() function, as in infile.eof() , is a bool function which is true if the EOF character has been read, false otherwise....
Read more >libspectre does not handle correctly when a FAKE %%EOF in the ...
FWIW I don't think it's a fake EOF. It is part of an embedded EPS file. The specification is not very clear about...
Read more >The eof Member Function
Every input file stream has a member function called eof, that can be used ... read past the end of the input file,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
should probably do it.
But that does not work asynchronously. I want a solution which would work while
prompt_toolkit
is actually waiting for user input.