Skip to content

Commit 80ef199

Browse files
figured out the threading on desktop/unix sortof
1 parent 8375824 commit 80ef199

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

internal_filesystem/lib/mpos/apps.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,9 @@ def execute_script_new_thread(scriptname, is_file, is_launcher, is_graphical):
7676
print("Starting camera with extra stack size!")
7777
stack=32*1024
7878
else:
79-
print("\n\n\nWHAAAAAAAAAAAAAAAAAA\n\n\n")
80-
#stack=16*1024 # somehow, on desktop, this causes a segfault... but the code isn't executed even!!!
81-
# [DEBUG 471155623] Connecting to wss://relay.damus.io
82-
# [DEBUG 471155623] Using SSL with no certificate verification
83-
stack=32*1024
79+
stack=16*1024
8480
_thread.stack_size(stack)
85-
print(f"app.py set stack size to {stack}")
81+
print(f"app.py set stack size for script to {stack}")
8682
_thread.start_new_thread(execute_script, (scriptname, is_file, is_launcher, is_graphical))
8783
except Exception as e:
8884
print("main.py: execute_script_new_thread(): error starting new thread thread: ", e)

internal_filesystem/lib/websocket_nostr_receive.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def printevents():
4343
time.sleep(3)
4444
#relay_manager.add_relay("wss://nostr-pub.wellorder.net")
4545
print("relaymanager adding")
46-
relay_manager.add_relay("wss://relay.damus.io")
46+
#relay_manager.add_relay("wss://relay.damus.io")
47+
relay_manager.add_relay("wss://relay.primal.net")
4748
time.sleep(3)
4849
print("relaymanager subscribing")
4950
relay_manager.add_subscription(subscription_id, filters)
@@ -82,9 +83,10 @@ def printevents():
8283
# 24KB is fine
8384
# somehow, if I run this in a thread, I get: can't create thread" at File "/lib/nostr/relay_manager.py", line 48, in open_connections
8485
# tried stack sizes from 18KB up to 32KB
85-
#_thread.stack_size(16*1024)
86-
#_thread.start_new_thread(printevents, ())
87-
printevents()
86+
# on unix/desktop, 24KB crashes, 26KB is fine
87+
_thread.stack_size(26*1024)
88+
_thread.start_new_thread(printevents, ())
89+
#printevents()
8890

8991

9092
#import gc

internal_filesystem/main.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@
1515
from mpos import apps
1616
apps.execute_script("builtin/system/button.py", True, False, False) # Install button handler through IRQ
1717

18+
def dummy():
19+
pass
20+
1821
import sys
1922
if sys.platform == "esp32":
2023
apps.auto_connect()
2124
else:
22-
pass
23-
#import _thread
24-
#import time
25+
# On unix/desktop, at least 24KB of stack size is needed in the REPL to make nostr work there
26+
import _thread
27+
_thread.stack_size(24*1024) # on unix/desktop, at least 24KB is needed for doing nostr connections from the REPL
28+
_thread.start_new_thread(dummy, ()) # not just setting the stack_size but actually starting a thread to apply this globally
2529

26-
#_thread.stack_size(32*1024)
27-
#time.sleep(1)
28-
apps.auto_connect()
2930
apps.restart_launcher()
3031

3132
# If we got this far without crashing, then no need to rollback the update:

0 commit comments

Comments
 (0)