From fc473b3246435ed88ef979a56d904cf6b2afcd20 Mon Sep 17 00:00:00 2001 From: James Tanner Date: Fri, 3 Jan 2014 09:46:16 -0500 Subject: [PATCH] Fixes #5146 Handle missing stdin when running under celery with rabbitmq or redis --- lib/ansible/runner/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 3318bcba2b..92b25788d0 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -405,8 +405,13 @@ class Runner(object): return flags try: - if not new_stdin: - self._new_stdin = os.fdopen(os.dup(sys.stdin.fileno())) + fileno = sys.stdin.fileno() + except ValueError: + fileno = None + + try: + if not new_stdin and fileno is not None: + self._new_stdin = os.fdopen(os.dup(fileno)) else: self._new_stdin = new_stdin