38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
# Python imports
|
|
import builtins
|
|
import threading
|
|
|
|
# Lib imports
|
|
|
|
# Application imports
|
|
from libs.event_system import EventSystem
|
|
|
|
|
|
# NOTE: Threads WILL NOT die with parent's destruction.
|
|
def threaded_wrapper(fn):
|
|
def wrapper(*args, **kwargs):
|
|
thread = threading.Thread(target = fn, args = args, kwargs = kwargs, daemon = False)
|
|
thread.start()
|
|
return thread
|
|
return wrapper
|
|
|
|
# NOTE: Threads WILL die with parent's destruction.
|
|
def daemon_threaded_wrapper(fn):
|
|
def wrapper(*args, **kwargs):
|
|
thread = threading.Thread(target = fn, args = args, kwargs = kwargs, daemon = True)
|
|
thread.start()
|
|
return thread
|
|
return wrapper
|
|
|
|
|
|
# NOTE: Just reminding myself we can add to builtins two different ways...
|
|
# __builtins__.update({"event_system": Builtins()})
|
|
builtins.APP_NAME = "PixelBash"
|
|
|
|
builtins.threaded = threaded_wrapper
|
|
builtins.daemon_threaded = daemon_threaded_wrapper
|
|
builtins.get_class = lambda x: globals()[x]
|
|
|
|
builtins.event_system = EventSystem()
|
|
|