@@ -327,11 +327,11 @@ control character (``Ctrl-D`` on Unix systems or ``Ctrl-Z`` on Windows).
327327Setting a Timeout for User Input
328328~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
329329
330- .. versionadded :: 7.4
331-
332- The timeout functionality for questions was introduced in Symfony 7.4 .
330+ Sometimes, commands can hang if a user takes too long to respond. For example,
331+ if interactive questions are used inside an open database transaction, a delayed
332+ response could leave the transaction open for too long .
333333
334- You can set a maximum time limit for user input by using the
334+ You can prevent this by setting a maximum time limit for input using the
335335:method: `Symfony\\ Component\\ Console\\ Question\\ Question::setTimeout ` method.
336336If the user doesn't respond within the specified timeout, a
337337:class: `Symfony\\ Component\\ Console\\ Exception\\ MissingInputException ` will be thrown::
@@ -346,7 +346,7 @@ If the user doesn't respond within the specified timeout, a
346346 $helper = new QuestionHelper();
347347
348348 $question = new Question('Please enter your answer');
349- $question->setTimeout(30); // 30 seconds timeout
349+ $question->setTimeout(30); // 30 seconds
350350
351351 try {
352352 $answer = $helper->ask($input, $output, $question);
@@ -359,15 +359,11 @@ If the user doesn't respond within the specified timeout, a
359359 return Command::SUCCESS;
360360 }
361361
362- This is particularly useful when you have interactive questions inside database
363- transactions or other time-sensitive operations where hanging indefinitely
364- could cause problems.
365-
366362.. note ::
367363
368364 The timeout only applies to interactive input streams. For non-interactive
369- streams (like pipes or files), the timeout setting is ignored and the
370- question behaves normally.
365+ streams (such as pipes or files), the timeout is ignored and the question
366+ behaves normally.
371367
372368You can also use timeouts with other question types such as
373369:class: `Symfony\\ Component\\ Console\\ Question\\ ConfirmationQuestion ` and
@@ -377,10 +373,14 @@ You can also use timeouts with other question types such as
377373
378374 // ...
379375 $question = new ConfirmationQuestion('Do you want to continue?', false);
380- $question->setTimeout(10); // 10 seconds timeout
376+ $question->setTimeout(10); // 10 seconds
381377
382378 $continue = $helper->ask($input, $output, $question);
383379
380+ .. versionadded :: 7.4
381+
382+ The timeout functionality for questions was introduced in Symfony 7.4.
383+
384384Hiding the User's Response
385385~~~~~~~~~~~~~~~~~~~~~~~~~~
386386
0 commit comments