You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
reduce CPU usage
This commit is contained in:
@@ -46,7 +46,9 @@ def _run_callback(callback, *args):
|
||||
|
||||
async def _process_callbacks_async():
|
||||
"""Process queued callbacks asynchronously."""
|
||||
import _thread
|
||||
while True:
|
||||
print(f"thread {_thread.get_ident()}: _process_callbacks_async")
|
||||
while _callback_queue:
|
||||
_log_debug("Processing callbacks queue...")
|
||||
try:
|
||||
@@ -64,7 +66,7 @@ async def _process_callbacks_async():
|
||||
except IndexError:
|
||||
_log_debug("Callback queue empty")
|
||||
break
|
||||
await asyncio.sleep(0.01) # Yield to other tasks
|
||||
await asyncio.sleep(0.5) # Yield to other tasks
|
||||
|
||||
class WebSocketApp:
|
||||
def __init__(
|
||||
|
||||
@@ -63,7 +63,8 @@ def printevents():
|
||||
print("checking pool....")
|
||||
try:
|
||||
event_msg = relay_manager.message_pool.get_event()
|
||||
print(f"event_msg: pubkey: {event_msg.event.public_key} created_at {event_msg.event.created_at}")
|
||||
#print(f"main code got event_msg: pubkey: {event_msg.event.public_key} created_at {event_msg.event.created_at}")
|
||||
print(f"main code got event_msg: pubkey: {event_msg.event.public_key} created_at {event_msg.event.created_at} with content '{event_msg.event.content}' and kind {event_msg.event.kind} and tags {event_msg.event.tags}")
|
||||
except Exception as e:
|
||||
#print(f"pool.get_event() got error: {e}")
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user