|
6 | 6 | import mpos.info |
7 | 7 | import mpos.ui |
8 | 8 |
|
9 | | -def good_stack_size(): |
10 | | - stacksize = 24*1024 # less than 20KB crashes on desktop when doing heavy apps, like LightningPiggy's Wallet connections |
11 | | - import sys |
12 | | - if sys.platform == "esp32": |
13 | | - stacksize = 16*1024 |
14 | | - return stacksize |
15 | | - |
16 | 9 | # Run the script in the current thread: |
17 | 10 | # Returns True if successful |
18 | 11 | def execute_script(script_source, is_file, classname, cwd=None): |
@@ -81,34 +74,6 @@ def execute_script(script_source, is_file, classname, cwd=None): |
81 | 74 | traceback.print_exception(type(e), e, tb) |
82 | 75 | return False |
83 | 76 |
|
84 | | -""" Unused: |
85 | | -# Run the script in a new thread: |
86 | | -# NOTE: check if the script exists here instead of launching a new thread? |
87 | | -def execute_script_new_thread(scriptname, is_file): |
88 | | - print(f"main.py: execute_script_new_thread({scriptname},{is_file})") |
89 | | - try: |
90 | | - # 168KB maximum at startup but 136KB after loading display, drivers, LVGL gui etc so let's go for 128KB for now, still a lot... |
91 | | - # But then no additional threads can be created. A stacksize of 32KB allows for 4 threads, so 3 in the app itself, which might be tight. |
92 | | - # 16KB allows for 10 threads in the apps, but seems too tight for urequests on unix (desktop) targets |
93 | | - # 32KB seems better for the camera, but it forced me to lower other app threads from 16 to 12KB |
94 | | - #_thread.stack_size(24576) # causes camera issue... |
95 | | - # NOTE: This doesn't do anything if apps are started in the same thread! |
96 | | - if "camtest" in scriptname: |
97 | | - print("Starting camtest with extra stack size!") |
98 | | - stack=32*1024 |
99 | | - elif "appstore" in scriptname: |
100 | | - print("Starting appstore with extra stack size!") |
101 | | - stack=24*1024 # this doesn't do anything because it's all started in the same thread |
102 | | - else: |
103 | | - stack=16*1024 # 16KB doesn't seem to be enough for the AppStore app on desktop |
104 | | - stack = mpos.apps.good_stack_size() |
105 | | - print(f"app.py: setting stack size for script to {stack}") |
106 | | - _thread.stack_size(stack) |
107 | | - _thread.start_new_thread(execute_script, (scriptname, is_file)) |
108 | | - except Exception as e: |
109 | | - print("main.py: execute_script_new_thread(): error starting new thread thread: ", e) |
110 | | -""" |
111 | | - |
112 | 77 | # Returns True if successful |
113 | 78 | def start_app(fullname): |
114 | 79 | from .content.package_manager import PackageManager |
|
0 commit comments