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

Irritating error on spawn with an instance already running #2551

Closed
Wumpf opened this issue Jun 28, 2023 · 2 comments · Fixed by #3501
Closed

Irritating error on spawn with an instance already running #2551

Wumpf opened this issue Jun 28, 2023 · 2 comments · Fixed by #3501
Assignees
Labels
😤 annoying Something in the UI / SDK is annoying to use 🐍 Python API Python logging API user-request This is a pressing issue for one of our users

Comments

@Wumpf
Copy link
Member

Wumpf commented Jun 28, 2023

Currently initializing with spawn=True will try to spawn a Rerun viewer but fail with this error message if one is already running on the same port:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Users/andreas/dev/rerun-io/rerun/rerun_py/rerun_sdk/rerun/__main__.py", line 16, in <module>
    main()
  File "/Users/andreas/dev/rerun-io/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 48)

.. and then silently connect to the existing one.

We should instead have two clearly defined options:

  • force_spawn: Fail spawning if a viewer is already running on that port
  • connect_or_spawn: Connect if a viewer is already running, otherwise spawn a new one

I'm suggesting to deprecate spawn and have it point to connect_or_spawn instead.

@Wumpf Wumpf added 🐍 Python API Python logging API 😤 annoying Something in the UI / SDK is annoying to use labels Jun 28, 2023
@Wumpf Wumpf added the user-request This is a pressing issue for one of our users label Sep 21, 2023
@emilk emilk added this to the 0.10 C++ milestone Sep 22, 2023
@emilk
Copy link
Member

emilk commented Sep 23, 2023

force_spawn could be called spawn_new, and automatically find a free port

@emilk
Copy link
Member

emilk commented Sep 25, 2023

Let's just improve the error message for 0.9 (if we can do so quickly), and save the proper fix for 0.10

@jleibs jleibs self-assigned this Sep 26, 2023
jleibs added a commit that referenced this issue Sep 28, 2023
…ng to spawn (#3501)

### What
- Resolves: #2551

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
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/3501) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/3501)
- [Docs
preview](https://rerun.io/preview/4c212d77d5ff82020b1df508dbdf5606c7bd8bad/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/4c212d77d5ff82020b1df508dbdf5606c7bd8bad/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
😤 annoying Something in the UI / SDK is annoying to use 🐍 Python API Python logging API user-request This is a pressing issue for one of our users
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants