feat: Automatically assign ports when available#96
Merged
Conversation
ascibisz
approved these changes
Oct 22, 2025
rugeli
approved these changes
Oct 23, 2025
rugeli
left a comment
There was a problem hiding this comment.
it's a handy feature! left a non-blocking note
rugeli
reviewed
Oct 23, 2025
|
|
||
|
|
||
| def get_available_port(default_port): | ||
| def get_available_ports(default_ports: List[int]) -> List[int]: |
There was a problem hiding this comment.
smart choice making it recursive! There is a recursion depth limitation with python but we're unlikely to hit it with just few ports so it's totally fine.
Although another thought I have, return a list of tuples like [(socket, port), ...] instead of just port numbers, then s.close() to close the sockets only after the servers running(or on error). This way should be safer because the ports stay reserved until we successfully started the servers on them
Contributor
Author
There was a problem hiding this comment.
This is a good idea, thank you, Ruge!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Change by @alexkhang18 that I'm PRing on his behalf, with a few minor changes. This change allows the
tfe-opencommand to automatically assign new port numbers if the current ones are occupied.Estimated review size: tiny, 5 minutes
Testing
pip install -e '.[dev]'tfe-open documentation/example_dataset. A new browser window should open.Video talk-through (🔊):
2025-10-13.15-57-42.mp4