wjszlachta-man commented on code in PR #53306:
URL: https://github.com/apache/spark/pull/53306#discussion_r2606559049


##########
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:
   Ok - you are right - so we want to handle these:
   
   - `POLLIN` and `POLLHUP` we want to break - when using `select()` these both 
return "ready for reading" - if peer hangs up reads will return 0 bytes
   - `POLLERR` and `POLLNVAL` we want to raise - `select()` will already raise 
on error



-- 
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