Skip to content

can't run python4andorid in debugger in vscode because shprint does not seem to work well in debugpy #3175

@guysoft

Description

@guysoft

The debgger used in vscode, debugpy, seems to not be able to run bulldozer because of code in python-for-android. When running a build sh.basename is called in the python3 recipe. The code is a more complex version of this code:

from pythonforandroid.logger import shprint
import sh

print(shprint(sh.basename, '/a/Python-3.11.5.tgz'))

When running without the debugger this works fine, but with the debugger I get:

 cd /home/guy/workspace/hand_tracker ; /usr/bin/env /home/guy/vpy/bin/python /home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 59539 -- /tmp/reproduce.py 
[INFO]:    -> running basename /a/Python-3.11.5.tgz
Traceback (most recent call last):                                                                                      
  File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 422, in _on_run
    cmd.send(self.sock)
  File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command.py", line 111, in send
    sock.sendall(("Content-Length: %s\r\n\r\n" % len(as_bytes)).encode("ascii"))
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 53, in run
    self._on_run()
  File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 432, in _on_run
    self.py_db.dispose_and_kill_all_pydevd_threads()
  File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 2558, in dispose_and_kill_all_pydevd_threads
    self._client_socket.close()
  File "/usr/lib/python3.11/socket.py", line 503, in close
    self._real_close()
  File "/usr/lib/python3.11/socket.py", line 497, in _real_close
    _ss.close(self)
OSError: [Errno 9] Bad file descriptor
6.71s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
Python-3.11.5.tgz

Plain sh works fine.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions