Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

妈呀,怎么会有那么多Bug?Oops, so much bug on this project. #1106

Closed
ghost opened this issue Jan 17, 2019 · 4 comments
Closed

妈呀,怎么会有那么多Bug?Oops, so much bug on this project. #1106

ghost opened this issue Jan 17, 2019 · 4 comments

Comments

@ghost
Copy link

ghost commented Jan 17, 2019

Environment data

  • PTVSD version: 4.2.0

  • OS and version: Linux 4.18.0-13-generic Hit-count conditional breakpoints #14-Ubuntu SMP Wed Dec 5 09:04:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

  • Python version (& distribution if applicable, e.g. Anaconda): Python 2.7.15+ (default, Oct 2 2018, 22:12:08)
    [GCC 8.2.0] on linux2

  • Using VS Code or Visual Studio: VS Code

Actual behavior

same as the #987

Expected behavior

everything is all right.

Steps to reproduce:

  1. change to 4.2.0+64.g274cf88
sudo python -m ptvsd --host localhost --port 7777 --pid `pgrep -f "/usr/bin/python ./manage.py"`
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/__main__.py", line 269, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/__main__.py", line 265, in main
    wait=args.wait)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/__main__.py", line 254, in handle_args
    attach_main(addr, name, *extra, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_attach.py", line 42, in attach_main
    run_python_code(pid, code, connect_debugger_tracing=True)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py", line 400, in run_python_code_linux
    assert '\'' not in python_code, 'Having a single quote messes with our command.'
AssertionError: Having a single quote messes with our command.

comment the line and run command below


sudo python -m ptvsd --host localhost --port 7777 --pid `pgrep -f "/usr/bin/python ./manage.py"`
Attaching with arch: i386:x86-64
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/__main__.py", line 269, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/__main__.py", line 265, in main
    wait=args.wait)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/__main__.py", line 254, in handle_args
    attach_main(addr, name, *extra, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_attach.py", line 42, in attach_main
    run_python_code(pid, code, connect_debugger_tracing=True)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/pydevd_attach_to_process/add_code_to_python_process.py", line 419, in run_python_code_linux
    raise RuntimeError('Could not find dll file to inject: %s' % target_dll)
RuntimeError: Could not find dll file to inject: /usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/pydevd_attach_to_process/attach_linux_amd64.so

add code to views.py

import ptvsd
ptvsd.enable_attach(address=('0.0.0.0', 7777), redirect_output=True)

ptvsd.wait_for_attach()

sudo python ./manage.py runserver --settings=web_admin.settings "0.0.0.0:8005"
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command.py", line 686, in process_net_command
    py_db.on_breakpoints_changed(remove=True)
TypeError: on_breakpoints_changed() got an unexpected keyword argument 'remove'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command.py", line 686, in process_net_command
    py_db.on_breakpoints_changed(remove=True)
TypeError: on_breakpoints_changed() got an unexpected keyword argument 'remove'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command.py", line 686, in process_net_command
    py_db.on_breakpoints_changed(remove=True)
TypeError: on_breakpoints_changed() got an unexpected keyword argument 'remove'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command.py", line 686, in process_net_command
    py_db.on_breakpoints_changed(remove=True)
TypeError: on_breakpoints_changed() got an unexpected keyword argument 'remove'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command.py", line 686, in process_net_command
    py_db.on_breakpoints_changed(remove=True)
TypeError: on_breakpoints_changed() got an unexpected keyword argument 'remove'

@karthiknadig
Copy link
Member

If you are installing ptvsd directly from github (to avoid #987), then try with the latest master. That should resolve the issue with on_debugbreakpoints_changed.

Launch in this manner:
sudo python -m ptvsd --host localhost --port 7777 ./manage.py

Launch with wait:
sudo python -m ptvsd --host localhost --port 7777 --wait ./manage.py

Note: --pid launches the debugger in client mode. This is currently restricted to launch/attach directly via IDE. Do not use this to launch the debugger manually.

@ghost
Copy link
Author

ghost commented Jan 17, 2019

Use NFS shared my runtime code to my mac.

Both server and mac has installed self-build whl with latest master.

I use vscode(版本 1.30.2 (1.30.2)) to attach remote debugger as

    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach (Remote Debug) Django",
            "type": "python",
            "request": "attach",
            "port": 7777,
            "host": remoteIP, 
            "django": true,
            "pathMappings": [
                {
                    "localRoot": "${workspaceRoot}",   // Local root  (where source and debugger running)
                    "remoteRoot": nfsSharedDirectory,  // Remote root (where remote code is running)
                    "program": "${workspaceFolder}/src/manage.py"
                }
            ]
        }
    ]
}

run as below and attach debugger in vscode:

python -m ptvsd --host 0.0.0.0 --port 7777 --wait ./manage.py runserver --settings=web_admin.settings "0.0.0.0:8005"

nothing happend and no 8005 port is listened.

run as no --wait shows:

sudo python -m ptvsd --host 0.0.0.0 --port 7777 ./manage.py runserver --settings=web_admin.settings "0.0.0.0:8005"
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/__main__.py", line 269, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/__main__.py", line 265, in main
    wait=args.wait)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/__main__.py", line 258, in handle_args
    debug_main(addr, name, kind, *extra, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_local.py", line 46, in debug_main
    run_file(address, name, *extra, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_local.py", line 80, in run_file
    run(argv, addr, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_local.py", line 141, in _run
    _pydevd.main()
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/pydevd.py", line 2104, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/pydevd.py", line 1447, in run
    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/pydevd.py", line 1454, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "./manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 49, in execute
    super(Command, self).execute(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in handle
    self.run(**options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 97, in run
    autoreload.main(self.inner_run, None, options)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 323, in main
    reloader(wrapped_main_func, args, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 294, in python_reloader
    exit_code = restart_with_reloader()
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 280, in restart_with_reloader
    exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 404, in new_spawnve
    return getattr(os, original_name)(mode, path, patch_args(args), env)
  File "/usr/lib/python2.7/os.py", line 573, in spawnve
    return _spawnvef(mode, file, args, env, execve)
  File "/usr/lib/python2.7/os.py", line 531, in _spawnvef
    pid = fork()
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 488, in new_fork
    _on_forked_process()
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 56, in _on_forked_process
    pydevd.settrace_forked()
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/pydevd.py", line 1890, in settrace_forked
    patch_multiprocessing=True,
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/pydevd.py", line 1649, in settrace
    stop_at_frame,
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/pydevd.py", line 1699, in _locked_settrace
    debugger.connect(host, port)  # Note: connect can raise error.
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/pydevd.py", line 683, in connect
    s = start_client(host, port)
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/pydevd_hooks.py", line 125, in <lambda>
    _start_client = (lambda h, p: start_client(daemon, h, p))
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/pydevd_hooks.py", line 71, in start_client
    sock, start_session = daemon.start_client((host, port))
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/daemon.py", line 208, in start_client
    with self.started():
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/daemon.py", line 109, in started
    self.start()
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/daemon.py", line 144, in start
    raise RuntimeError('already started')
RuntimeError: already started
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_trace_dispatch_regular.py", line 379, in __call__
    py_db.notify_thread_not_alive(get_current_thread_id(t))
  File "/usr/local/lib/python2.7/dist-packages/ptvsd/_vendored/pydevd/pydevd.py", line 802, in notify_thread_not_alive
    was_notified = thread.additional_info.pydev_notify_kill
AttributeError: 'NoneType' object has no attribute 'pydev_notify_kill'

Mamma Mia(Mario cry out)

@karthiknadig
Copy link
Member

Try running django with, --noreload and --nothreading.
sudo python -m ptvsd --host 0.0.0.0 --port 7777 ./manage.py runserver --noreload --nothreading --settings=web_admin.settings "0.0.0.0:8005"

When using --wait debugger will wait for you to attach before running your code.

Also pathMapping should not have program. use this:

"configurations": [
        {
            "name": "Attach (Remote Debug) Django",
            "type": "python",
            "request": "attach",
            "port": 7777,
            "host": remoteIP, 
            "django": true,
            "pathMappings": [
                {
                    "localRoot": "${workspaceRoot}",   // Local root  (where source and debugger running)
                    "remoteRoot": nfsSharedDirectory,  // Remote root (where remote code is running)
                }
            ]
        }
    ]

@karthiknadig
Copy link
Member

Closing this for now, please reopen if needed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant