def _on_exit(self, fd):
        # Unregister the fd with the select loop
        self.select_task.unregister_read(fd)

        # And set the proper local fd to None
        if fd == self._outfd:
            self._outfd = None
        elif fd == self._errfd:
            self._errfd = None
        else:
            raise Exception(fd % "_onexit called with unknown fd, %d")

        # If both fds have been set to None, it's safe to call the
        # onexit callback (since we've notified the out/err callbacks for
        # all available data)
        if self._errfd is None and self._outfd is None:
            if self.exit_callback:
                # There is a *very* narrow race condition between both fds
                # being closed by the child process and the exit code being
                # properly set by the Popen abstractions.  As a result, we'll
                # call wait() instead of poll() here.  99% of the time,
                # this will return instantly, and the other 1% we'll slow
                # down are select loop.  This is sufficiently rare, so it
                # should be fine.
                returncode = self._popen.wait()
                self.exit_callback(returncode)
dataset/ETHPy150Open facebook/sparts/sparts/tasks/select.py/ProcessStreamHandler._on_exit/swapped operands of `%`