File: forking_correct_parent.yml

package info (click to toggle)
python-mitogen 0.3.36-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,708 kB
  • sloc: python: 24,457; sh: 198; makefile: 74; perl: 19; ansic: 18
file content (54 lines) | stat: -rw-r--r-- 1,373 bytes parent folder | download | duplicates (2)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

- name: integration/runner/forking_correct_parent.yml
  hosts: test-targets
  tasks:
  - include_tasks: ../_mitogen_only.yml

  # Verify mitogen_task_isolation=fork forks from "virginal fork parent", not
  # shared interpreter, but only if forking is enabled (e.g. that's never true
  # on Python 2.4).

  - mitogen_action_script:
      script: |
        self._connection._connect()
        result['uses_fork'] = (
          self._connection.init_child_result['fork_context'] is not None
        )
    register: forkmode

  - name: get regular process ID.
    custom_python_detect_environment:
    register: regular_proc

  - name: get force-forked process ID again.
    custom_python_detect_environment:
    register: fork_proc
    vars:
      mitogen_task_isolation: fork

  - assert:
      that:
      - fork_proc.pid != regular_proc.pid
      fail_msg: |
        fork_proc={{ fork_proc }}
        regular_proc={{ regular_proc }}

  - assert:
      that: fork_proc.ppid != regular_proc.pid
      fail_msg: |
        fork_proc={{ fork_proc }}
        regular_proc={{ regular_proc }}
    when:
      - forkmode.uses_fork

  - assert:
      that: fork_proc.ppid == regular_proc.pid
      fail_msg: |
        fork_proc={{ fork_proc }}
        regular_proc={{ regular_proc }}
    when:
      - not forkmode.uses_fork

  tags:
    - forking_correct_parent
    - mitogen_only