You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm still having some problems with select.select raising an exception "ValueError: filedescriptor out of range in select()" in src/prompt_toolkit/input/posix_utils.py", line 72 if the file descriptor number is too large (>1023). This happens when passing in a pipe instead of stdin during testing. It seems to be similar to problems that were already discussed in #354.
What makes this especially problematic is that the exception occurs inside the prompt loop which results in the prompt (and pytest) hanging indefinitely. A simple test to reproduce the problem:
importosfromtypingimportNamedTupleimportpytestfromprompt_toolkitimportPromptSessionfromprompt_toolkit.inputimportcreate_pipe_inputfromprompt_toolkit.input.baseimportPipeInputfromprompt_toolkit.outputimportDummyOutput@pytest.fixturedefprompt():
file_descriptors= []
try: # if an "OSError: Too many open files" is thrown, you may need to adjust the fp limit (`ulimit -n`)for_inrange(512): # this should be enough to create a file descriptor > 1023read_fd, write_fd=os.pipe()
file_descriptors.extend([read_fd, write_fd])
withcreate_pipe_input() asinput_:
session=PromptSession(input=input_, output=DummyOutput())
yieldPrompt(session, input_)
finally:
forfdinfile_descriptors:
os.close(fd)
classPrompt(NamedTuple):
session: PromptSessioninput: PipeInputdeftest_too_many_open_files(prompt):
prompt.input.send_text(f"foobar\n")
# the prompt will hang if `select.select` is used because it causes an exception "filedescriptor out of range"prompt.session.prompt("foobar")
As discussed in #354, it is possible to easily fix this by replacing select.select with select.poll. I have added a patch which seemingly fixes this: select_poll_patch.txt
The text was updated successfully, but these errors were encountered:
Hi, I'm still having some problems with
select.select
raising an exception "ValueError: filedescriptor out of range in select()" insrc/prompt_toolkit/input/posix_utils.py"
, line 72 if the file descriptor number is too large (>1023). This happens when passing in a pipe instead of stdin during testing. It seems to be similar to problems that were already discussed in #354.What makes this especially problematic is that the exception occurs inside the prompt loop which results in the prompt (and pytest) hanging indefinitely. A simple test to reproduce the problem:
As discussed in #354, it is possible to easily fix this by replacing
select.select
withselect.poll
. I have added a patch which seemingly fixes this:select_poll_patch.txt
The text was updated successfully, but these errors were encountered: