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

launch_gateway fails to parse server port when enabling a JVM debug port #511

Open
ehigham opened this issue Mar 7, 2023 · 3 comments
Open
Labels

Comments

@ehigham
Copy link

ehigham commented Mar 7, 2023

When calling launch_gateway with javaopts=['-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005'] it'll fail to parse the server port from stdout:

File py4j/java_gateway.py:337, in launch_gateway(port, jarpath, classpath, javaopts, die_on_exit, redirect_stdout, redirect_stderr, daemonize_redirect, java_path, create_new_process_group, enable_auth, cwd, return_proc, use_shell)
    331 proc = Popen(
    332     command, stdout=PIPE, stdin=PIPE, stderr=stderr, cwd=cwd,
    333     **popen_kwargs)
    335 # Determine which port the server started on (needed to support
    336 # ephemeral ports)
--> 337 _port = int(proc.stdout.readline())
    339 # Read the auth token from the server if enabled.
    340 _auth_token = None

ValueError: invalid literal for int() with base 10: b'Listening for transport dt_socket at address: 5005\n'
@HyukjinKwon
Copy link
Member

Thanks for reporting this. Are you interested in making a PR?

@HyukjinKwon HyukjinKwon added the bug label Mar 8, 2023
ehigham added a commit to ehigham/py4j that referenced this issue Mar 8, 2023
When users expose JVM debug ports, the JVM prints information about
the debug port on initialization (ie before `main` is invoked).
Discard stdout noise until the port is successfully read.
@ehigham
Copy link
Author

ehigham commented Mar 8, 2023

Thanks for reporting this. Are you interested in making a PR?

Sure :)

@ehigham
Copy link
Author

ehigham commented Jul 27, 2023

@HyukjinKwon can someone take a look at the PR please?

ehigham added a commit to ehigham/py4j that referenced this issue Apr 23, 2024
When users expose JVM debug ports, the JVM prints information about
the debug port on initialization (ie before `main` is invoked).
Discard stdout noise until the port is successfully read.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants