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 curses.setupterm() error in pause module #47851
Conversation
When run playbook in celery task, curses.setupterm() will be failed ``` File "<frozen importlib._bootstrap>", line 675, in _load File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File "/Users/guang/.virtualenvs/ansible/lib/python3.6/site-packages/ansible/plugins/action/pause.py", line 45, in <module> curses.setupterm() TypeError: argument must be an int, or have a fileno() method. ```
Hi @ibuler, thank you for submitting this pull-request! |
@@ -44,7 +44,7 @@ | |||
try: | |||
curses.setupterm() | |||
HAS_CURSES = True | |||
except curses.error: | |||
except (curses.error, TypeError): |
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 think that is right but it could just as easily be except Exception:
(reason being that any failure there would mean that we don't have a working curses and need to resort to the fallback code)
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.
Just wondering why once was picked other the other
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.
in general we try to narrow down exceptions to avoid 'capture globbing' errors
@ibuler Could you please add a |
* [Bugfix] curses.setupterm() error When run playbook in celery task, curses.setupterm() will be failed ``` File "<frozen importlib._bootstrap>", line 675, in _load File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File "/Users/guang/.virtualenvs/ansible/lib/python3.6/site-packages/ansible/plugins/action/pause.py", line 45, in <module> curses.setupterm() TypeError: argument must be an int, or have a fileno() method. ``` * Add changelog Co-authored-by: Sam Doran <sdoran@redhat.com> (cherry picked from commit c3fc2d2) Co-authored-by: 老广 <ibuler@qq.com>
* [Bugfix] curses.setupterm() error When run playbook in celery task, curses.setupterm() will be failed ``` File "<frozen importlib._bootstrap>", line 675, in _load File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File "/Users/guang/.virtualenvs/ansible/lib/python3.6/site-packages/ansible/plugins/action/pause.py", line 45, in <module> curses.setupterm() TypeError: argument must be an int, or have a fileno() method. ``` * Add changelog Co-authored-by: Sam Doran <sdoran@redhat.com> (cherry picked from commit c3fc2d2) Co-authored-by: 老广 <ibuler@qq.com> Co-authored-by: 老广 <ibuler@qq.com>
SUMMARY
When run playbook in celery task, curses.setupterm() will be failed, In celery worker may be no sys.stdin fileno, so catch this error
ISSUE TYPE
COMPONENT NAME
plugins/pause
ANSIBLE VERSION
ADDITIONAL INFORMATION