added wrappers, temp disabled all modules

This commit is contained in:
BuildTools
2015-11-23 22:17:40 +01:00
parent ab42a0cb65
commit 70b4db5318
9 changed files with 217 additions and 115 deletions

24
thread_utils.py Normal file
View File

@@ -0,0 +1,24 @@
import threading
"""
Quick implementation of a @synchronized and @asynchronized decorators
"""
#To be replaced by bukkit scheduler.
"""
def sync(lock=None):
def decorator(wrapped):
def wrapper(*args, **kwargs):
with lock:
return wrapped(*args, **kwargs)
return wrapper
return decorator
"""
def async(daemon = True):
def decorator(function):
def wrapper(*args,**kwargs):
thread = threading.Thread(target=function,args=args,kwargs=kwargs)
thread.daemon = daemon
thread.start()
return wrapper
return decorator