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

stdout/err capture #4

Open
embray opened this issue Jan 16, 2021 · 1 comment
Open

stdout/err capture #4

embray opened this issue Jan 16, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@embray
Copy link
Owner

embray commented Jan 16, 2021

When calling GAP functions like Print() which print directly to standard I/O, although it works, it doesn't pass through Python's sys.stdout, so it can't be captured by other Python code that captures I/O. In particular, pytest can't correctly capture the output of doctests where this happens.

This might be something to fix in pytest (maybe there is a plugin or option for this but I can't find one). But it might still be better for integration with other Python code if standard I/O passed through the standard Python streams somehow rather than directly to the file descriptor.

@embray embray added the enhancement New feature or request label Jan 18, 2021
@embray
Copy link
Owner Author

embray commented Jan 18, 2021

One way might be to direct GAP's stdout to a pipe, and have a thread to read from that pipe (esp. while running any GAP calls) and redirect it to sys.stdout. Using a pipe + thread would be advantageous over just capturing to a variable, so that calling GAP functions that progressively write something to the stream is actually streamed and not just output all at once when the call is completed.

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

No branches or pull requests

1 participant