Cornea/src/new-src/__builtins__.py

44 lines
1.4 KiB
Python
Raw Normal View History

2022-02-15 06:51:06 +00:00
# Python imports
2023-03-28 02:21:28 +00:00
import builtins
import threading
2022-02-15 06:51:06 +00:00
# Lib imports
# Application imports
2022-10-23 07:08:53 +00:00
from utils.event_system import EventSystem
from utils.endpoint_registry import EndpointRegistry
2023-03-28 02:21:28 +00:00
from utils.keybindings import Keybindings
from utils.logger import Logger
2022-10-23 07:08:53 +00:00
from utils.settings import Settings
2022-02-15 06:51:06 +00:00
2022-09-01 21:35:21 +00:00
# NOTE: Threads WILL NOT die with parent's destruction.
def threaded_wrapper(fn):
def wrapper(*args, **kwargs):
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=False).start()
return wrapper
# NOTE: Threads WILL die with parent's destruction.
def daemon_threaded_wrapper(fn):
def wrapper(*args, **kwargs):
threading.Thread(target=fn, args=args, kwargs=kwargs, daemon=True).start()
return wrapper
2022-02-15 06:51:06 +00:00
# NOTE: Just reminding myself we can add to builtins two different ways...
# __builtins__.update({"event_system": Builtins()})
builtins.app_name = "Cornea"
2023-03-28 02:21:28 +00:00
builtins.keybindings = Keybindings()
2022-10-23 07:08:53 +00:00
builtins.event_system = EventSystem()
builtins.endpoint_registry = EndpointRegistry()
2023-03-28 02:21:28 +00:00
builtins.settings = Settings()
builtins.logger = Logger(settings.get_home_config_path(), \
_ch_log_lvl=settings.get_ch_log_lvl(), \
_fh_log_lvl=settings.get_fh_log_lvl()).get_logger()
2022-10-23 07:08:53 +00:00
2023-03-28 02:21:28 +00:00
builtins.threaded = threaded_wrapper
builtins.daemon_threaded = daemon_threaded_wrapper
builtins.event_sleep_time = 0.05