# Is callback function is thread safe?

**URL:** <https://forum.ansible.com/t/is-callback-function-is-thread-safe/33654>\
**Category:** Ansible Developer\
**Created:** [August 21, 2020, 8:46am UTC](https://forum.ansible.com/t/is-callback-function-is-thread-safe/33654 "2020-08-21T08:46:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nihanth\_Joseph](https://avatars.discourse-cdn.com/v4/letter/n/bcef8e/32.png) [@Nihanth\_Joseph](https://forum.ansible.com/u/Nihanth_Joseph)\
**Post date:** [August 21, 2020, 8:46am UTC](https://forum.ansible.com/t/is-callback-function-is-thread-safe/33654/1 "2020-08-21T08:46:24Z")

</div>

I have written playbooks to manage 100s of machines and i am using callback plugins to capture the output of each task and generate reports at the end. Since I am using forks (eg. 20) do i have to handle each output in thread safe manner?

eg:

class CallbackModule(CallbackBase):  
def **init** (self):  
output =

def v2\_runner\_on\_ok(self, result, \*\*kwargs):  
with self.lock:

# capture output

def v2\_playbook\_on\_stats(self, stats):

# generate report
