PHP 8.3.31
Preview: deadlock_detecting_lock.py Size: 755 B
/proc/self/root/opt/imunify360/venv/lib64/python3.11/site-packages/defence360agent/internals/deadlock_detecting_lock.py

import asyncio


class DeadlockError(Exception):
    """Error raised if DeadlockDetectingLock detects deadlock"""


class DeadlockDetectingLock:
    """
    Lock that detects deadlock when it is about to be
    acquired by the same task that already holds it.
    """

    def __init__(self):
        self._lock = asyncio.Lock()
        self._owner = None

    def locked(self):
        return self._lock.locked()

    async def __aenter__(self):
        curr_task = asyncio.current_task()
        if self._owner == curr_task:
            raise DeadlockError()
        await self._lock.acquire()
        self._owner = curr_task
        return self

    async def __aexit__(self, exc_type, exc, tb):
        self._owner = None
        self._lock.release()

Directory Contents

Dirs: 1 × Files: 13

Name Size Perms Modified Actions
- drwxr-xr-x 2026-06-08 20:23:14
Edit Download
1.18 KB lrw-r--r-- 2026-05-26 21:20:44
Edit Download
13.52 KB lrw-r--r-- 2026-05-26 21:20:44
Edit Download
755 B lrw-r--r-- 2026-05-26 21:20:44
Edit Download
4.87 KB lrw-r--r-- 2026-05-26 21:20:44
Edit Download
462 B lrw-r--r-- 2026-05-26 21:20:44
Edit Download
14.32 KB lrw-r--r-- 2026-05-26 21:20:44
Edit Download
195 B lrw-r--r-- 2026-05-26 21:20:44
Edit Download
14.81 KB lrw-r--r-- 2026-05-26 21:20:44
Edit Download
1.07 KB lrw-r--r-- 2026-05-26 21:20:44
Edit Download
5.68 KB lrw-r--r-- 2026-05-26 21:20:44
Edit Download
3.02 KB lrw-r--r-- 2026-05-26 21:20:44
Edit Download
11.24 KB lrw-r--r-- 2026-05-26 21:20:44
Edit Download
0 B lrw-r--r-- 2026-05-26 21:20:44
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).