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

Python: remove unconditional sleep on spawn #4010

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

teh-cmc
Copy link
Member

@teh-cmc teh-cmc commented Oct 25, 2023

Removes the unconditional sleep(0.5) on the spawn path in python, improving latency.

This mimics what happens in the new Rust/C/C++ spawn APIs:

crate::spawn(opts)?;
// Give the newly spawned Rerun Viewer some time to bind.
//
// NOTE: The timeout only covers the TCP handshake: if no process is bound to that address
// at all, the connection will fail immediately, irrelevant of the timeout configuration.
// For that reason we use an extra loop.
for _ in 0..5 {
if TcpStream::connect_timeout(&connect_addr, Duration::from_secs(1)).is_ok() {
break;
}
std::thread::sleep(Duration::from_millis(100));
}

What

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested demo.rerun.io (if applicable)
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

@teh-cmc teh-cmc added 🐍 Python API Python logging API 🧑‍💻 dev experience developer experience (excluding CI) include in changelog labels Oct 25, 2023
@teh-cmc teh-cmc force-pushed the cmc/binary_spawn_4_python_sleep branch from 8e928e7 to 3da1275 Compare October 25, 2023 16:21
Copy link
Member

@jleibs jleibs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh nice, should have realized this opportunity when I added the check.

@teh-cmc teh-cmc merged commit 107c833 into main Oct 26, 2023
34 checks passed
@teh-cmc teh-cmc deleted the cmc/binary_spawn_4_python_sleep branch October 26, 2023 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧑‍💻 dev experience developer experience (excluding CI) include in changelog 🐍 Python API Python logging API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants