mirror of
https://github.com/saphid/frame-control.git
synced 2026-10-06 06:00:33 +02:00
Mac in the headset: no viewer cleanup while a Show is launching; relay pump always ends
Review round 10: a Show replacing its own stream could have its new viewer ended by the cleanup; a viewer reset left the delayed relay pending. Verified: the relay delivers what's queued, then closes the agent side. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7f769ca2f0
commit
484a50a189
3 files changed
+19
-4
No files matched your search
@@ -173,9 +173,11 @@ class Relay:
|
||||
writer.close()
|
||||
|
||||
async def pump():
|
||||
while data := await reader.read(65536):
|
||||
await queue.put((self.loop.time() + self.delay, data))
|
||||
await queue.put((0, None))
|
||||
try:
|
||||
while data := await reader.read(65536):
|
||||
await queue.put((self.loop.time() + self.delay, data))
|
||||
finally: # EOF or a reset: either way the sender finishes and closes
|
||||
queue.put_nowait((0, None))
|
||||
|
||||
sender, pumper = asyncio.ensure_future(send()), asyncio.ensure_future(pump())
|
||||
done, _ = await asyncio.wait({sender, pumper}, return_when=asyncio.FIRST_COMPLETED)
|
||||
|
||||
@@ -98,6 +98,9 @@ class Helpers(unittest.TestCase):
|
||||
mv.shows += 1 # Show pressed during the wait: leave the new viewer alone
|
||||
mv._end_viewer_browser(gen)
|
||||
self.assertEqual(len(calls), 1)
|
||||
mv.launching = 1 # a Show replacing its own stream is still launching
|
||||
mv._end_viewer_browser(mv.shows)
|
||||
self.assertEqual(len(calls), 1)
|
||||
|
||||
|
||||
class WS:
|
||||
|
||||
+11
-1
@@ -129,6 +129,7 @@ class MacView:
|
||||
self.supervisor = None
|
||||
self.closing = False
|
||||
self.shows = 0 # counts Show presses, so a late cleanup can't close a new viewer
|
||||
self.launching = 0 # Shows in progress (one may be replacing its own stream)
|
||||
self.shown = set() # sources with a viewer out there, connected or retrying
|
||||
self.browser_flags = list(BROWSER_FLAGS)
|
||||
|
||||
@@ -280,6 +281,15 @@ class MacView:
|
||||
# ---- viewers on the Frame ----
|
||||
|
||||
def show(self, src, quality="balanced", width=None, height=None):
|
||||
with self.lock:
|
||||
self.launching += 1
|
||||
try:
|
||||
return self._show(src, quality, width, height)
|
||||
finally:
|
||||
with self.lock:
|
||||
self.launching -= 1
|
||||
|
||||
def _show(self, src, quality, width, height):
|
||||
if src != "test" and not src.startswith(("window:", "display:", "separate:")):
|
||||
raise MacViewError("Pick a window or display to show.")
|
||||
self.shows += 1
|
||||
@@ -337,7 +347,7 @@ class MacView:
|
||||
2026-09-28), so once nothing is shown, end it. It runs with a profile
|
||||
of its own, so nothing else is touched."""
|
||||
time.sleep(2) # the viewers close their windows first
|
||||
if self.shown or self.shows != shows:
|
||||
if self.shown or self.shows != shows or self.launching:
|
||||
return
|
||||
try:
|
||||
self.run("pkill -f '[f]rame-control/mac-view|[d]ata/frame-mac-view' || true", timeout=10)
|
||||
|
||||
Reference in new issue
Block a user