File: mitogen_shutdown_all.py

package info (click to toggle)
python-mitogen 0.3.26-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,456 kB
  • sloc: python: 22,134; sh: 183; makefile: 74; perl: 19; ansic: 18
file content (31 lines) | stat: -rw-r--r-- 903 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Arrange for all ContextService connections to be torn down unconditionally,
required for reliable LRU tests.
"""

import ansible_mitogen.connection
import ansible_mitogen.services

from ansible.plugins.action import ActionBase


class ActionModule(ActionBase):
    # Running this for every host is pointless.
    BYPASS_HOST_LOOP = True

    def run(self, tmp=None, task_vars=None):
        if not isinstance(self._connection,
                          ansible_mitogen.connection.Connection):
            return {
                'skipped': True,
            }

        self._connection._connect()
        binding = self._connection.get_binding()
        return {
            'changed': True,
            'result': binding.get_service_context().call_service(
                service_name='ansible_mitogen.services.ContextService',
                method_name='shutdown_all',
            )
        }