gaogaotiantian commented on code in PR #53306:
URL: https://github.com/apache/spark/pull/53306#discussion_r2604660541


##########
python/pyspark/accumulators.py:
##########
@@ -266,12 +266,27 @@ def handle(self) -> None:
         auth_token = self.server.auth_token  # type: ignore[attr-defined]
 
         def poll(func: Callable[[], bool]) -> None:
+            poller = None
+            if os.name == "posix":
+                # On posix systems use poll to avoid problems with file 
descriptor
+                # numbers above 1024.
+                poller = select.poll()
+                poller.register(self.rfile, select.POLLIN)
+
             while not self.server.server_shutdown:  # type: 
ignore[attr-defined]
                 # Poll every 1 second for new data -- don't block in case of 
shutdown.
-                r, _, _ = select.select([self.rfile], [], [], 1)
-                if self.rfile in r and func():
+                if poller is not None:
+                    # Unlike select, poll timeout is in millis. Rule out error 
events.
+                    r = [fd for fd, event in poller.poll(1000) if event & 
select.POLLIN]

Review Comment:
   Okay I took some time on this and I think my implementation lacks error 
checking as well which I will fix later. However, we need to deal with errors 
here. If the socket has some issues, we will busy loop here forever because 
`poller.poll()` does not raise an exception.
   
   We should break on `POLLHUP` and raise an error on `POLLERR` and `POLLNVAL`. 
We also need to confirm that there's no other event set.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to