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 is delayed? #45

Open
tsdev opened this issue Jul 28, 2017 · 5 comments
Open

Stdout is delayed? #45

tsdev opened this issue Jul 28, 2017 · 5 comments

Comments

@tsdev
Copy link

tsdev commented Jul 28, 2017

When I run the following command the STDOUT from Matlab is not transferred:

S = {'a':1.0}
mlab.disp(S)

Strangely, I get the output later after running a few more commands.

@bastibe
Copy link
Owner

bastibe commented Aug 9, 2017

Interesting. I have looked at this a bit, but I can't find the problem. It seems that Matlab buffers some of its outputs, and only prints them to stdout on the next drawnow. This is unfortunate, but there doesn't seem to be anything transplant can do to fix this short of repeatedly calling drawnow.

@tsdev
Copy link
Author

tsdev commented Aug 9, 2017

Thanks for looking into it. Strangely it only happens sporadically.

@bastibe
Copy link
Owner

bastibe commented Aug 9, 2017

I'll keep this open in case I stumble across a solution

@bareil76-code
Copy link

bareil76-code commented Jan 27, 2020

First, good job. It is working much better than the engine provided by Matlab . I am running Python 3.6 with Matlab 2018b and I just don't have any stdout at all. I post this here because I am pretty sure it is related.

I tried playing with your start reader function but nothing worked.

`def _start_reader(self): 

    """Starts an asynchronous reader that echos everything the remote says"""
    stdout = self.process.stdout
    def reader():
        """Echo what the remote says using print"""
        for line in iter(stdout.readline, bytes()):
            print(line.decode(), end='')
    Thread(target=reader, daemon=True).start()`

I tried the following and I am "getting in of thread" and never getting print('getting out of thread') and never 'getting line'

    `def reader():

        print('getting in of thread')
        """Echo what the remote says using print"""
        for line in iter(stdout.readline, bytes()):
            print('getting line')
            print(line.decode(), end='')
        print('getting out of thread')`

So I guess that stdout.readline is never returning anything. Hope it helps

@bastibe
Copy link
Owner

bastibe commented Jan 28, 2020

I'm assuming you are running Windows? Matlab simply does not write to stdout on Windows (as is noted in the README). Which is just sad, but there's nothing to be done about it as far as I know.

If you need to capture output, you can always make your function calls with evalc. Not pretty or elegant, but that always works.

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

3 participants