Files
Jack 1459724ba3 Update to 7.10.0
[+] Add Mail Server to the left menu.
[+] Add Mail Server - WebMail (requires Mail Server upgrade 5.1)
[+] Add WP Toolkit Plugin, Theme installation.
[+] Add Mail Server Login info.
[+] Add Mail Server WebMail One-click Login (requires Mail Server upgrade 5.2).
[+] Redesigned Security - Firewall.

[*] Optimized Mass Mail sending speed.
[*] Optimized the CPU usage problem of aaPanel startup service.

[-] Fix apache application, renew SSL issue.
[-] Fix Let's Encrypt account registeration failed.
[-] Fix openlitespeed using capital letters on domain name caused the website cannot be accessed issue.
[-] Fix problem of failure to reset root password in some versions of MariaDB.
[-] Fix an error in modifying Permission in some cases of MySQL.
[-] Fix the Website category display problem.
2024-08-09 09:57:59 +08:00

43 lines
1.0 KiB
Python

from contextlib import contextmanager
import threading
# 存储所有已排序的线程锁
_local = threading.local()
@contextmanager
def acquire(*locks, timeout=-1):
'''
@name 避免死锁
@author Zhj
@param locks<[]threading.Lock> 线程锁
@param timeout<integer> 最长阻塞时间/秒
@return None
'''
# 升序排序
locks = sorted(locks, key=lambda x: id(x))
# 确保按顺序加锁
acquired = getattr(_local, 'acquired', [])
if timeout <= 0 and acquired and max(id(lock) for lock in acquired) >= id(locks[0]):
raise RuntimeError('Lock Order Violation')
# 加锁
acquired.extend(locks)
_local.acquired = acquired
try:
# 按顺序加锁
for lock in locks:
lock.acquire(timeout=timeout)
# 转出程序控制权
yield
finally:
# 倒序释放锁
for lock in reversed(locks):
try:
lock.release()
except: pass
del (acquired[-len(locks):],)