# Ansible hangs while executing a python script

**URL:** <https://forum.ansible.com/t/ansible-hangs-while-executing-a-python-script/14450>\
**Category:** Ansible Project\
**Created:** [January 29, 2014, 3:55am UTC](https://forum.ansible.com/t/ansible-hangs-while-executing-a-python-script/14450 "2014-01-29T03:55:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arulraj\_J](https://avatars.discourse-cdn.com/v4/letter/a/bc79bd/32.png) [@Arulraj\_J](https://forum.ansible.com/u/Arulraj_J)\
**Post date:** [January 29, 2014, 3:55am UTC](https://forum.ansible.com/t/ansible-hangs-while-executing-a-python-script/14450/1 "2014-01-29T03:55:45Z")

</div>

Along with ansible tasks i was calling a python script named ‘rbupgrade.py’. During this python script execution anisble hangs and couldn’t move further.

[root@cu028 ~]# ps -ef|grep py  
root 19725 19588 0 09:22 pts/0 00:00:00 grep py  
root 27594 1 0 Jan26 ? 00:00:00 /opt/collabnet/teamforge/runtime/bin/wrapper/python /opt/collabnet/teamforge/runtime/scripts/timestamp  
sf-admin 27806 1 0 Jan26 ? 00:00:00 /opt/collabnet/teamforge/runtime/bin/wrapper/python /opt/collabnet/teamforge/runtime/scripts/timestamp  
root 29513 1 0 Jan26 ? 00:00:00 /opt/collabnet/teamforge/runtime/bin/wrapper/python /opt/collabnet/teamforge/runtime/scripts/timestamp  
root 29623 29620 0 Jan26 ? 00:00:00 /opt/collabnet/teamforge/runtime/bin/wrapper/python /opt/collabnet/teamforge/runtime/scripts/timestamp  
root 30469 1 0 Jan26 ? 00:00:00 /bin/sh -c /usr/bin/python /root/.ansible/tmp/ansible-1390720907.78-64524173882964/command; rm -rf /root/.ansible/tmp/ansible-1390720907.78-64524173882964/ \>/dev/null 2\>&1  
root 30488 30469 0 Jan26 ? 00:00:00 /usr/bin/python /root/.ansible/tmp/ansible-1390720907.78-64524173882964/command  
root 30489 30488 0 Jan26 ? 00:00:00 [rbupgrade.py]   
[root@cu028 ~]#

Please help me in this problem…

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [January 29, 2014, 4:13pm UTC](https://forum.ansible.com/t/ansible-hangs-while-executing-a-python-script/14450/2 "2014-01-29T16:13:30Z")

</div>

Follow the instructions in this thread: [https://groups.google.com/forum/#!msg/ansible-project/JdZWzLeZMmk/93W-42MP9U0J](https://groups.google.com/forum/#!msg/ansible-project/JdZWzLeZMmk/93W-42MP9U0J)

Once you have the trace data, we may be able to offer more advice.

I have a hunch that the "rbupgrade.py" script may not like not being run without a shell or may be asking for input. Perhaps try using the "shell:" module instead of "command:".

---

<div class="post-metadata">

**Author:** ![Arulraj\_J](https://avatars.discourse-cdn.com/v4/letter/a/bc79bd/32.png) [@Arulraj\_J](https://forum.ansible.com/u/Arulraj_J)\
**Post date:** [February 3, 2014, 7:25am UTC](https://forum.ansible.com/t/ansible-hangs-while-executing-a-python-script/14450/3 "2014-02-03T07:25:43Z")

</div>

This is were the trace stops  
python -m trace --trace /root/.ansible/tmp/ansible-1390720907.78-64524173882964/command

— modulename: subprocess, funcname: close\_unregister\_and\_remove  
subprocess.py(1357): poller.unregister(fd)  
subprocess.py(1358): self.\_fd2file[fd].close()  
subprocess.py(1359): self.\_fd2file.pop(fd)  
subprocess.py(1395): for fd, mode in ready:  
subprocess.py(1386): while self.\_fd2file:  
subprocess.py(1387): try:  
subprocess.py(1388): ready = poller.poll(self.\_remaining\_time(endtime))  
— modulename: subprocess, funcname: \_remaining\_time  
subprocess.py(766): if endtime is None:  
subprocess.py(767): return None

FYI, called python script ‘rbupgrade.py’ will run locally in the ansible server itself.

---

<div class="post-metadata">

**Author:** ![Arulraj\_J](https://avatars.discourse-cdn.com/v4/letter/a/bc79bd/32.png) [@Arulraj\_J](https://forum.ansible.com/u/Arulraj_J)\
**Post date:** [February 10, 2014, 4:04am UTC](https://forum.ansible.com/t/ansible-hangs-while-executing-a-python-script/14450/4 "2014-02-10T04:04:10Z")

</div>

I even tried by executing as shell command, but no help.

Is this a bug in latest ansible? i didn’t face this problem with earlier versions…

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [February 10, 2014, 1:31pm UTC](https://forum.ansible.com/t/ansible-hangs-while-executing-a-python-script/14450/5 "2014-02-10T13:31:18Z")

</div>

We are pretty sure nothing has changed here.

Is “rbupgrade” something standard? What is it’s usual running time?

Most likely the script is clinging on to standard input, you might wish to try feeding /dev/null into the program.
