We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
While I'm at it:
random_port() relies on "chance", i.e. it bets on a random port will be available:
random_port()
> proffer::random_port function (lower = 49152L, upper = 65355L) { sample(seq.int(from = lower, to = upper, by = 1L), size = 1L) }
In R (>= 4.0.0) we can easily check if a port is available, e.g.
> parallelly:::canPortBeUsed function (port) { port <- assertPort(port) ns <- asNamespace("parallel") if (!exists("serverSocket", envir = ns, mode = "function")) return(NA) serverSocket <- get("serverSocket", envir = ns, mode = "function") suspendInterrupts <- get("suspendInterrupts", envir = asNamespace("base"), mode = "function") suspendInterrupts({ con <- tryCatch(serverSocket(port), error = identity) }) free <- inherits(con, "connection") if (free) close(con) free } <environment: namespace:parallelly>
So, you could use that technique to increase the chances for getting a port that's actually available. That's now parallelly::freePort() works.
parallelly::freePort()
The text was updated successfully, but these errors were encountered:
e7c8f1d
Thanks for such a helpful suggestion! Happy to invoke parallelly::freePort() directly on the ephemeral port range.
Sorry, something went wrong.
No branches or pull requests
While I'm at it:
random_port()
relies on "chance", i.e. it bets on a random port will be available:Suggestion
In R (>= 4.0.0) we can easily check if a port is available, e.g.
So, you could use that technique to increase the chances for getting a port that's actually available. That's now
parallelly::freePort()
works.The text was updated successfully, but these errors were encountered: