# PyMutex error in lxc module when using lxc\_container (Debian Trixie)

**URL:** <https://forum.ansible.com/t/pymutex-error-in-lxc-module-when-using-lxc-container-debian-trixie/44304>\
**Category:** Get Help\
**Tags:** ubuntu, debian-trixie\
**Created:** [August 15, 2025, 3:21pm UTC](https://forum.ansible.com/t/pymutex-error-in-lxc-module-when-using-lxc-container-debian-trixie/44304 "2025-08-15T15:21:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scherer](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@scherer](https://forum.ansible.com/u/scherer)\
**Post date:** [August 15, 2025, 3:21pm UTC](https://forum.ansible.com/t/pymutex-error-in-lxc-module-when-using-lxc-container-debian-trixie/44304/1 "2025-08-15T15:21:19Z")

</div>

**Issue**

When I execute and Ansible lxc\_container task, I get no error in Ansible but the tasks fails on the remote end with “Fatal Python error: PyMutex\_Unlock: unlocking mutex that is not locked“

Pre-requisites:

- I’ve created a simple playbook to replicate the issue.
- LXC host running
- Debian 13 (13.0 Trixie)
- Python (3.13.5)
- LXC (1:6.0.4-4+b3)
- python3-lxc (1:5.0.0-2+b3)
- LXC container (also running Debian 13, but I’ve tried it with other versions such as bookworm and it has the same effect)

Playbook/Role:

```auto
- name: test container command
  lxc_container:
    name: ezra3
    state: started
    container_command: |
      echo -e “Hello World\n” >/root/hello_world.txt

```

I’ve ran the playbook with -vvvv and can see the error in the output. I’ve then preserved the tmp files and executed it again manually on the lxc host.

```auto
root@martha1:~/.ansible/tmp$ python3 ansible-tmp-1755260077.5821028-8449-254242578688725/AnsiballZ_lxc_container.py 
Fatal Python error: PyMutex_Unlock: unlocking mutex that is not locked
Python runtime state: initialized

Current thread 0x00007fe8bb3f6100 (most recent call first):
  File "/tmp/ansible_lxc_container_payload_7dh2sfdk/ansible_lxc_container_payload.zip/ansible_collections/community/general/plugins/modules/lxc_container.py", line 934 in _execute_command
  File "/tmp/ansible_lxc_container_payload_7dh2sfdk/ansible_lxc_container_payload.zip/ansible_collections/community/general/plugins/modules/lxc_container.py", line 1156 in _started
  File "/tmp/ansible_lxc_container_payload_7dh2sfdk/ansible_lxc_container_payload.zip/ansible_collections/community/general/plugins/modules/lxc_container.py", line 1624 in run
  File "/tmp/ansible_lxc_container_payload_7dh2sfdk/ansible_lxc_container_payload.zip/ansible_collections/community/general/plugins/modules/lxc_container.py", line 1744 in main
  File "/tmp/ansible_lxc_container_payload_7dh2sfdk/ansible_lxc_container_payload.zip/ansible_collections/community/general/plugins/modules/lxc_container.py", line 1748 in <module>
  File "<frozen runpy>", line 88 in _run_code
  File "<frozen runpy>", line 98 in _run_module_code
  File "<frozen runpy>", line 226 in run_module
  File "/root/.ansible/tmp/ansible-tmp-1755260077.5821028-8449-254242578688725/AnsiballZ_lxc_container.py", line 122 in invoke_module
  File "/root/.ansible/tmp/ansible-tmp-1755260077.5821028-8449-254242578688725/AnsiballZ_lxc_container.py", line 249 in _ansiballz_main
  File "/root/.ansible/tmp/ansible-tmp-1755260077.5821028-8449-254242578688725/AnsiballZ_lxc_container.py", line 259 in <module>

Extension modules: _lxc (total: 1)

{"changed": true, "lxc_container": {"interfaces": ["eth0", "lo"], "ips": ["192.168.1.180", "fd40:5d5f:73d0:5a9a:1266:6aff:fee9:9a17"], "state": "running", "init_pid": 71820, "name": "ezra3"}, "invocation": {"module_args": {"name": "ezra3", "state": "started", "container_command": "echo -e \"Hello World\\n\" >/root/hello_world.txt\n", "template": "ubuntu", "backing_store": "dir", "vg_name": "lxc", "fs_type": "ext4", "fs_size": "5G", "container_log": false, "container_log_level": "INFO", "clone_snapshot": false, "archive": false, "archive_compression": "gzip", "template_options": null, "config": null, "thinpool": null, "directory": null, "zfs_root": null, "lv_name": "ezra3", "lxc_path": null, "container_config": null, "clone_name": null, "archive_path": null}}}

```

The exact same playbook works fine on an older Debian 12 (bookworm) host.

---

<div class="post-metadata">

**Author:** ![lavoiesl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lavoiesl/32/9426_2.png) [@lavoiesl](https://forum.ansible.com/u/lavoiesl)\
**Post date:** [September 15, 2025, 5:08pm UTC](https://forum.ansible.com/t/pymutex-error-in-lxc-module-when-using-lxc-container-debian-trixie/44304/2 "2025-09-15T17:08:31Z")

</div>

Same here. Did you find any workaround?
