Skip to content

Commit ef4a6e2

Browse files
nostr works on esp32 but sometimes fragmentation and thread limits
1 parent 8df64d4 commit ef4a6e2

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

internal_filesystem/lib/threading.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def start(self):
1212
# In MicroPython, _thread.start_new_thread doesn't support daemon threads directly
1313
# We store the daemon attribute for compatibility, but it may not affect termination
1414
#_thread.stack_size(32*1024)
15+
_thread.stack_size(12*1024)
1516
_thread.start_new_thread(self.run, ())
1617

1718
def run(self):

internal_filesystem/lib/websocket_nostr_receive.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,12 @@ def printevents():
3737
print("relaymanager subscribing")
3838
relay_manager.add_subscription(subscription_id, filters)
3939
time.sleep(3) # allow the connections to open
40-
4140
print("opening connections") # after this, CPU usage goes high and stays there
4241
relay_manager.open_connections({"cert_reqs": ssl.CERT_NONE}) # NOTE: This disables ssl certificate verification
4342
time.sleep(10) # allow the connections to open
44-
4543
print("publishing:")
4644
relay_manager.publish_message(message)
4745
time.sleep(10) # allow the messages to send
48-
4946
print("printing events:")
5047
#while relay_manager.message_pool.has_events():
5148
for _ in range(10):
@@ -70,13 +67,15 @@ def printevents():
7067
# [DEBUG 408724546] Connecting to wss://relay.damus.io
7168
# [DEBUG 408724547] Using SSL with no certificate verification
7269
# 24KB is fine
73-
_thread.stack_size(18*1024)
74-
_thread.start_new_thread(printevents, ())
75-
#printevents()
70+
# 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
71+
# tried stack sizes from 18KB up to 32KB
72+
#_thread.stack_size(48*1024)
73+
#_thread.start_new_thread(printevents, ())
74+
printevents()
7675

7776

78-
import gc
79-
for _ in range(50):
80-
collect = gc.collect()
81-
print(f"MEMFREE: {gc.mem_free()}")
82-
time.sleep(1)
77+
#import gc
78+
#for _ in range(50):
79+
# collect = gc.collect()
80+
# print(f"MEMFREE: {gc.mem_free()}")
81+
# time.sleep(1)

0 commit comments

Comments
 (0)