You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
callbacks aren't being called in time
This commit is contained in:
@@ -46,6 +46,7 @@ def _run_callback(callback, *args):
|
||||
def _process_callbacks():
|
||||
"""Process queued callbacks."""
|
||||
while _callback_queue:
|
||||
print("processing callbacks queue...")
|
||||
try:
|
||||
callback, args = _callback_queue.popleft()
|
||||
if callback is not None:
|
||||
@@ -252,11 +253,13 @@ class WebSocketApp:
|
||||
self.session = aiohttp.ClientSession(headers=self.header)
|
||||
async with self.session.ws_connect(self.url, ssl=ssl_context) as ws:
|
||||
self.ws = ws
|
||||
print("running on_open callback...")
|
||||
_run_callback(self.on_open, self)
|
||||
print("done running on_open callback.")
|
||||
self._start_ping_thread()
|
||||
|
||||
async for msg in ws:
|
||||
print(f"received msg: {msg.type} - {msg.data}")
|
||||
print(f"websocket.py received msg: type {msg.type} - {msg.data[0:20]}")
|
||||
if not self.running:
|
||||
break
|
||||
|
||||
|
||||
@@ -8,11 +8,12 @@ from nostr.message_type import ClientMessageType
|
||||
|
||||
#filters = Filters([Filter(authors=[<a nostr pubkey in hex>], kinds=[EventKind.TEXT_NOTE])])
|
||||
#filters = Filters([Filter(authors="04c915daefee38317fa734444acee390a8269fe5810b2241e5e6dd343dfbecc9", kinds=[EventKind.TEXT_NOTE])])
|
||||
timestamp = round(time.time()-1000)
|
||||
#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)])
|
||||
|
||||
subscription_id = "ihopethisworks2" + str(time.time())
|
||||
subscription_id = "test" + str(round(time.time()))
|
||||
request = [ClientMessageType.REQUEST, subscription_id]
|
||||
json.dumps(request)
|
||||
request.extend(filters.to_json_array())
|
||||
|
||||
@@ -3,8 +3,11 @@ import websocket
|
||||
import _thread
|
||||
import time
|
||||
|
||||
def on_open(wsapp):
|
||||
print(f"on_open works here")
|
||||
|
||||
def on_message(wsapp, message):
|
||||
print(f"got message: {message}")
|
||||
print(f"got message: {message[0:20]}")
|
||||
|
||||
def on_ping(wsapp, message):
|
||||
print("Got a ping! A pong reply has already been automatically sent.")
|
||||
@@ -21,7 +24,7 @@ def on_error(wsapp, message):
|
||||
|
||||
#wsapp = websocket.WebSocketApp("wss://echo.websocket.events", on_message=on_message, on_ping=on_ping, on_pong=on_pong, on_error=on_error)
|
||||
|
||||
wsapp = websocket.WebSocketApp("wss://relay.damus.io", on_message=on_message, on_ping=on_ping, on_pong=on_pong, on_error=on_error)
|
||||
wsapp = websocket.WebSocketApp("wss://relay.damus.io", on_message=on_message, on_ping=on_ping, on_pong=on_pong, on_error=on_error, on_open=on_open)
|
||||
|
||||
#wsapp = websocket.WebSocketApp("wss://relay.primal.net", on_message=on_message, on_ping=on_ping, on_pong=on_pong, on_error=on_error)
|
||||
|
||||
@@ -45,7 +48,9 @@ print("sending it")
|
||||
#wsapp.send_text('["REQ","index3",{"kinds":[9735]}]')
|
||||
#wsapp.send_text('["REQ","index3",{"kinds":[9735], "since": 1745086888}]')
|
||||
tosend = '["REQ","index3",{"kinds":[9735], "since": '
|
||||
tosend += str(round(time.time()-1000))
|
||||
tosend += str(round(time.time()-500))
|
||||
#tosend += str(round(time.time()-2000))
|
||||
#tosend += str(round(time.time()-10000))
|
||||
tosend += '}]'
|
||||
print(f"sending: {tosend}")
|
||||
wsapp.send_text(tosend)
|
||||
|
||||
Reference in New Issue
Block a user