MCPcopy Create free account
hub / github.com/pywebio/PyWebIO / refresh_msg

Function refresh_msg

demos/chat_room.py:19–33  ·  view source on GitHub ↗

send new message to current session

(my_name)

Source from the content-addressed store, hash-verified

17
18
19async def refresh_msg(my_name):
20 """send new message to current session"""
21 global chat_msgs
22 last_idx = len(chat_msgs)
23 while True:
24 await asyncio.sleep(0.5)
25 for m in chat_msgs[last_idx:]:
26 if m[0] != my_name: # only refresh message that not sent by current user
27 put_markdown('`%s`: %s' % m, sanitize=True, scope='msg-box')
28
29 # remove expired message
30 if len(chat_msgs) > MAX_MESSAGES_CNT:
31 chat_msgs = chat_msgs[len(chat_msgs) // 2:]
32
33 last_idx = len(chat_msgs)
34
35
36async def main():

Callers 1

mainFunction · 0.85

Calls 1

put_markdownFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…