You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
add stack size prints
This commit is contained in:
@@ -191,6 +191,8 @@ class WebSocketClient:
|
||||
await self.send(b"", self.CLOSE)
|
||||
|
||||
async def _read_frame(self):
|
||||
import micropython
|
||||
print(f"aiohttp_ws.py thread stack used: {micropython.stack_use()}")
|
||||
header = await self.reader.read(2)
|
||||
if len(header) != 2: # pragma: no cover
|
||||
# raise OSError(32, "Websocket connection closed")
|
||||
@@ -211,7 +213,9 @@ class WebSocketClient:
|
||||
mask = await self.reader.read(4)
|
||||
print(f"mask is {mask}")
|
||||
payload = await self.reader.read(length)
|
||||
print(f"payload is {payload}")
|
||||
print(f"payload is {payload} with actual length {len(payload)}")
|
||||
if len(payload) != length:
|
||||
print("wrong payload length, this should be ignored!")
|
||||
if has_mask: # pragma: no cover
|
||||
payload = bytes(x ^ mask[i % 4] for i, x in enumerate(payload))
|
||||
return opcode, payload
|
||||
|
||||
@@ -7,6 +7,7 @@ class Queue:
|
||||
def __init__(self, maxsize=0):
|
||||
self._queue = []
|
||||
self.maxsize = maxsize # 0 means unlimited
|
||||
#self.maxsize = 4 # limit to avoid stack overflow
|
||||
self._lock = _thread.allocate_lock() if _thread else None
|
||||
|
||||
def put(self, item):
|
||||
|
||||
@@ -297,6 +297,8 @@ class WebSocketApp:
|
||||
#self._start_ping_task() this ping task isn't part of the protocol, pings are sent by the server
|
||||
|
||||
async for msg in ws:
|
||||
import micropython
|
||||
print(f"websocket.py _connect_and_run thread stack used: {micropython.stack_use()}")
|
||||
_log_debug(f"websocket.py _connect_and_run received msg: type={msg.type}, length: {len(msg.data)} and data={str(msg.data)[:50]}...")
|
||||
if not self.running:
|
||||
_log_debug("Not running, breaking message loop")
|
||||
|
||||
@@ -13,12 +13,15 @@ from nostr.message_type import ClientMessageType
|
||||
#timestamp = round(time.time()-50)
|
||||
#timestamp = round(time.time()) # going for zero events to check memory use
|
||||
|
||||
# on esp32, it needs this correction:
|
||||
#timestamp = time.time() + 946684800 - 1000
|
||||
import sys
|
||||
if sys.platform == "esp32":
|
||||
# on esp32, it needs this correction:
|
||||
timestamp = time.time() + 946684800 - 1000
|
||||
else:
|
||||
timestamp = round(time.time()-1000)
|
||||
#timestamp = round(time.time()-1000)
|
||||
#timestamp = round(time.time()-5000)
|
||||
|
||||
timestamp = round(time.time()-100)
|
||||
#timestamp = round(time.time()-1000)
|
||||
#timestamp = round(time.time()-5000)
|
||||
#filters = Filters([Filter(authors="04c915daefee38317fa734444acee390a8269fe5810b2241e5e6dd343dfbecc9", kinds=[9735], since=timestamp)])
|
||||
filters = Filters([Filter(kinds=[9735], since=timestamp)])
|
||||
|
||||
@@ -31,6 +34,8 @@ message = json.dumps(request)
|
||||
print(f"sending this: {message}")
|
||||
|
||||
def printevents():
|
||||
import micropython
|
||||
print(f"at the start, thread stack used: {micropython.stack_use()}")
|
||||
print("relaymanager")
|
||||
relay_manager = RelayManager()
|
||||
time.sleep(3)
|
||||
@@ -43,21 +48,22 @@ def printevents():
|
||||
time.sleep(3) # allow the connections to open
|
||||
print("opening connections") # after this, CPU usage goes high and stays there
|
||||
relay_manager.open_connections({"cert_reqs": ssl.CERT_NONE}) # NOTE: This disables ssl certificate verification
|
||||
time.sleep(10) # allow the connections to open
|
||||
time.sleep(2) # allow the connections to open
|
||||
print("publishing:")
|
||||
relay_manager.publish_message(message)
|
||||
time.sleep(10) # allow the messages to send
|
||||
time.sleep(2) # allow the messages to send
|
||||
print("printing events:")
|
||||
#while relay_manager.message_pool.has_events():
|
||||
for _ in range(10):
|
||||
# allowing 30 seconds for stuff to come in...
|
||||
for _ in range(30):
|
||||
time.sleep(1)
|
||||
print(".")
|
||||
try:
|
||||
event_msg = relay_manager.message_pool.get_event()
|
||||
print(event_msg.event.content)
|
||||
print(f"event_msg: pubkey: {event_msg.event.public_key} created_at {event_msg.event.created_at}")
|
||||
except Exception as e:
|
||||
print(f"pool.get_event() got error: {e}")
|
||||
print("60 seconds passed, closing:")
|
||||
print("30 seconds passed, closing:")
|
||||
relay_manager.close_connections()
|
||||
|
||||
# new thread so REPL stays available
|
||||
|
||||
Reference in New Issue
Block a user