Skip to content

Instantly share code, notes, and snippets.

@Simsso
Created September 26, 2023 20:26
Show Gist options
  • Select an option

  • Save Simsso/7cba4e5f24dee8a509052270cf6c73d1 to your computer and use it in GitHub Desktop.

Select an option

Save Simsso/7cba4e5f24dee8a509052270cf6c73d1 to your computer and use it in GitHub Desktop.
def synchronized(func):
"""Wraps a function with a threading lock."""
lock = threading.Lock()
def wrapper(*args, **kwargs):
with lock:
return func(*args, **kwargs)
return wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment