-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cli blockingioerror #11934
Fix cli blockingioerror #11934
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the initiative to fix this 💯
To double-check, the ticket description referred to 2.x
minor series, is this occurring in 3.x
too?
try: | ||
print(output) | ||
except BlockingIOError: | ||
print_blocking(output) | ||
|
||
|
||
def print_success(*args: Any) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we need a docstring here because the linter checks for any issues in the same module where the changes are being made (even if unrelated with the code changes). And we can't merge without making the linter happy 😅
import sys | ||
from typing import Any, Text, NoReturn | ||
|
||
import rasa.shared.utils.io | ||
|
||
|
||
def print_blocking(string) -> None: | ||
"""Save fcntl settings and restore them after print().""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unfamiliar with fcntl
, could we expand the docstring a bit more about the need for this.
def print_blocking(string) -> None: | ||
"""Save fcntl settings and restore them after print().""" | ||
save = fcntl.fcntl(sys.stdout.fileno(), fcntl.F_GETFL) | ||
new = save & ~os.O_NONBLOCK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we add some comment above this line to explain what it's doing concisely.
import sys | ||
from typing import Any, Text, NoReturn | ||
|
||
import rasa.shared.utils.io | ||
|
||
|
||
def print_blocking(string) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add a unit test for this new function?
@trammell One more thing about |
@ancalita that is a very good point. I'm going to retract this PR and implement the changes discussed above. |
Proposed changes:
Add
print_blocking()
and try/except block to manage blocking print errors in CLI.Fixes https://rasa-open-source.atlassian.net/browse/OSS-183
Status (please check what you already did):
black
(please check Readme for instructions)