# Ansible custom module to start long running process

**URL:** <https://forum.ansible.com/t/ansible-custom-module-to-start-long-running-process/25313>\
**Category:** Ansible Developer\
**Created:** [August 23, 2017, 8:02am UTC](https://forum.ansible.com/t/ansible-custom-module-to-start-long-running-process/25313 "2017-08-23T08:02:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![senthil-t](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@senthil-t](https://forum.ansible.com/u/senthil-t)\
**Post date:** [August 23, 2017, 8:02am UTC](https://forum.ansible.com/t/ansible-custom-module-to-start-long-running-process/25313/1 "2017-08-23T08:02:56Z")

</div>

Hi,

I’m developing a “custom ansible module” to start a long running background process on the remote host.  
As per the response for the post [https://github.com/ansible/ansible/issues/28264](https://github.com/ansible/ansible/issues/28264), Ansible connection stays  
until all the processes are terminated.  
And that matches with the ansible generated code below.

p = subprocess.Popen([‘/usr/bin/python’, module], env=os.environ, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)  
(stdout, stderr) = p.communicate(json\_params)

p.communicate(json\_params) waits until all the processes (including child) are terminated.i

is there a way to do this ? async or systemd is not an option since my custom module is going to invoke another python script which will start the process.

Thanks in advance!!!

Regards,  
Senthil
