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

Check if another process is already listening on the port before trying to spawn #3501

Merged
merged 1 commit into from
Sep 28, 2023

Conversation

jleibs
Copy link
Member

@jleibs jleibs commented Sep 27, 2023

What

Before we spawn, we now try connecting to the port to see if it's in use or not, allowing us to print a better error message and not waste time kicking off a subprocess that's just going to fail.

Before:

$ python docs/code-examples/point3d_random.py
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/jleibs/rerun/rerun_py/rerun_sdk/rerun/__main__.py", line 16, in <module>
    main()
  File "/home/jleibs/rerun/rerun_py/rerun_sdk/rerun/__main__.py", line 12, in main
    exit(bindings.main(sys.argv))
RuntimeError: Failed to bind TCP address "0.0.0.0:9876". Another Rerun instance is probably running. Address already in use (os error 98)

After:

$ python docs/code-examples/point3d_random.py
DEV ENVIRONMENT DETECTED! Re-importing rerun from: /home/jleibs/rerun/rerun_py/rerun_sdk
Found existing process on port 9876. Trying to connect.

Checklist

@jleibs jleibs added the 🐍 Python API Python logging API label Sep 27, 2023
@jleibs jleibs changed the title Check if someone is already listening on the port before trying to spawn Check if another process is already listening on the port before trying to spawn Sep 27, 2023
@jleibs jleibs marked this pull request as ready for review September 27, 2023 17:39
@teh-cmc teh-cmc self-requested a review September 28, 2023 06:53
@jleibs jleibs merged commit 8c910aa into main Sep 28, 2023
27 of 33 checks passed
@jleibs jleibs deleted the jleibs/better_existing_viewer branch September 28, 2023 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Irritating error on spawn with an instance already running
2 participants