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

First go at using a free port instead of defaulting to 8050 #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AustinJRoberts
Copy link

This PR is meant to address the issue of most of our Dash demos trying to use port 8050.
Instead, the code looks for a free port and uses that.

Two draw backs are that it makes the readme less clear and requires the user to read console output.

Changing the .yaml file should likely be considered as will

Comment on lines +31 to +32
A URL of the form http://127.0.0.1:***** will be printed in the console.
Open in the url in your browser.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
A URL of the form http://127.0.0.1:***** will be printed in the console.
Open in the url in your browser.
A URL of the form `http://127.0.0.1:*****` is printed in the console.
Open the URL in your browser.

Not commenting on the solution just on this particular phrasing :-)

Copy link
Contributor

@randomir randomir left a comment

Choose a reason for hiding this comment

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

It's not clear to me what use case you're addressing with this. Running multiple Dash demos / same app instances?

@@ -307,6 +308,13 @@ def update_score_figure(feature_score_data, data_key):
return children


def find_free_port():
with socket.socket() as s:
s.bind(('', 0)) # Bind to a free port provided by the host.
Copy link
Contributor

Choose a reason for hiding this comment

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

This might have unwanted effects in LeapIDE -- depending on (random) port chosen, user might not get a notification about port/service being available (bottom-right pop-up notification).

@AustinJRoberts
Copy link
Author

It's not clear to me what use case you're addressing with this. Running multiple Dash demos / same app instances?

Yes. When providing demos and talks, it is not uncommon to show more than one demo in a row want to have the apps ready to go. Or even have two different instances of the same app in two windows to not lose visuals when comparing. It has come up in multiple talks for me. However, it may understandably not be a priority outside of edge users like me.

@randomir
Copy link
Contributor

randomir commented Jan 19, 2023

I see. In that case I would recommend a less random approach (on average) like we do here. Same approach is used by Jupyter, for example. You can set the base port to be around 8000.

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

Successfully merging this pull request may close these issues.

None yet

3 participants