diff mbox series

server/process: remove need for ConnectionWriter to have self self-reference

Message ID 20250121175634.3723325-2-chris.laplante@agilent.com
State New
Headers show
Series server/process: remove need for ConnectionWriter to have self self-reference | expand

Commit Message

chris.laplante@agilent.com Jan. 21, 2025, 5:56 p.m. UTC
From: Chris Laplante <chris.laplante@agilent.com>

It's a minor thing, but the mystery was too enticing to pass up.

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
---
 lib/bb/server/process.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--
2.43.0
diff mbox series

Patch

diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index 4b35be62cd..8dacb41f47 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -12,6 +12,7 @@ 

 import bb
 import bb.event
+import collections
 import logging
 import multiprocessing
 import threading
@@ -250,7 +251,9 @@  class ProcessServer():

                     # Where to write events to
                     writer = ConnectionWriter(ui_fds[0])
-                    self.event_handle = bb.event.register_UIHhandler(writer, True)
+                    # bb.event expects an 'event' property on whatever you pass as a UI handler
+                    ConnectionWriterEventWrapper = collections.namedtuple('ConnectionWriterEventWrapper', ['event'])
+                    self.event_handle = bb.event.register_UIHhandler(ConnectionWriterEventWrapper(writer), True)
                     self.event_writer = writer

                     # Where to read commands from
@@ -850,8 +853,6 @@  class ConnectionWriter(object):
     def __init__(self, fd):
         self.writer = multiprocessing.connection.Connection(fd, readable=False)
         self.wlock = multiprocessing.Lock()
-        # Why bb.event needs this I have no idea
-        self.event = self

     def _send(self, obj):
         gc.disable()