Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCOOP hangs on attempting to read remote stdout (on stable version - 0.7, r1.1) #43

Open
Carnou opened this issue Jun 15, 2016 · 1 comment

Comments

@Carnou
Copy link

Carnou commented Jun 15, 2016

Using python 3.5.1 and the latest stable version of SCOOP (i.e. the one available through pip - version 0.7, revision 1.1), any time I run any of the example files, e.g. python -m scoop -vv --hostfile hostfile rssDoc.py, it hangs at the end. I see a message such as "Closing workers on solomon (8 workers)", and nothing more. Debugging through pdb showed me that it was blocking as it tried to read the process.stdout in the close function of workerLaunch.py.

I solved this by making a function to make the stream non-blocking before reading it, and used that on both process.stdout and process.stderr:

import fcntl
import os

def _makeStreamNonBlocking(self, stream):
    flags = fcntl.fcntl(stream.fileno(), fcntl.F_GETFL)
    fcntl.fcntl(stream.fileno(), fcntl.F_SETFL, flags | os.O_NDELAY)

def close(self):
         """Connection(s) cleanup."""
         # Ensure everything is cleaned up on exit
         scoop.logger.debug('Closing workers on {0}.'.format(self))

         # Output child processes stdout and stderr to console
         for process in self.subprocesses:
             if process.stdout is not None:
                 self._makeStreamNonBlocking(process.stdout)
                 sys.stdout.write(process.stdout.read().decode("utf-8"))
                 sys.stdout.flush()

             if process.stderr is not None:
                 self._makeStreamNonBlocking(process.stderr)
                 sys.stderr.write(process.stderr.read().decode("utf-8"))
                 sys.stderr.flush()


I see this code I modified doesn't even exist in the current version on github. Should I simply favor the github version over the "currently stable" one?

@Carnou Carnou changed the title SCOOP hangs on attempting to read remote stdout SCOOP hangs on attempting to read remote stdout (on stable version - 0.7, r1.1) Jun 15, 2016
@soravux
Copy link
Owner

soravux commented Sep 11, 2016

This section has changed since the stable version. Does it happens with the development version (the master branch)? If so, please keep me posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants