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

lib.lsl_open_stream does not block until the stream is fully ready #176

Open
mscheltienne opened this issue Dec 8, 2022 · 0 comments
Open

Comments

@mscheltienne
Copy link

I discovered this using the Python API, but it's most likely present everywhere. See below the desription and a MWE in Python:

In the Python API, StreamInlet.open_stream(timeout) is not completely blocking. If you create an outlet, create an inlet, open the stream on the inlet and then immediately push. a sample and pull a sample (with a positive timeout to wait until a sample appears in the inlet), it will hang out for the duration of the timeout specified in pull_sample because the sample was pushed before the stream was completely open. At least that's my interpretation. Here is a MWE:

import time
from pylsl import StreamInfo, StreamInlet, StreamOutlet, resolve_streams
sinfo = StreamInfo("test", "", 1, 0.0, "string", "test-stream")
outlet = StreamOutlet(sinfo)
stream = resolve_streams(wait_time=2)[0]
inlet = StreamInlet(stream)
inlet.open_stream(timeout=1000)
time.sleep(0.1)  # comment to show the issue
outlet.push_sample("1")
data, ts = inlet.pull_sample(timeout=2)
assert len(data) == 1

With the sleep, data is received; without the sleep, inlet.pull_sample exit after 2 seconds and data is None .

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

1 participant