Is callback function is thread safe?

13 views
Skip to first unread message

Nihanth Joseph

unread,
Aug 21, 2020, 4:46:24 AM8/21/20
to Ansible Development
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
Reply all
Reply to author
Forward
0 new messages