Skip to content

Commit

Permalink
fix: [python] debugging python project cause frozen
Browse files Browse the repository at this point in the history
When multiple applications are open, debugging the Python project causes the applications to freeze.

Log: as title

bug: https://pms.uniontech.com/bug-view-267559.html
  • Loading branch information
LiHua000 authored and deepin-ci-robot committed Aug 8, 2024
1 parent 7b5679b commit 1f47bc9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/plugins/python/python/pythondebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool PythonDebug::prepareDebug(const QString &fileName, QString &retMsg)
}


bool PythonDebug::requestDAPPort(const QString &uuid, const QString &kit,
bool PythonDebug::requestDAPPort(const QString &ppid, const QString &kit,
const QString &projectPath,
const QString &fileName,
QString &retMsg)
Expand All @@ -71,7 +71,7 @@ bool PythonDebug::requestDAPPort(const QString &uuid, const QString &kit,
"com.deepin.unioncode.interface",
"launch_python_dap");
QString projectCachePath = CustomPaths::projectCachePath(projectPath);
msg << uuid
msg << ppid
<< kit
<< d->interpreterPath
<< fileName
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/python/python/pythondebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PythonDebug : public QObject
~PythonDebug();

bool prepareDebug(const QString &fileName, QString &retMsg);
bool requestDAPPort(const QString &uuid, const QString &kit,
bool requestDAPPort(const QString &ppid, const QString &kit,
const QString &projectPath,
const QString &fileName,
QString &retMsg);
Expand Down
9 changes: 6 additions & 3 deletions src/tools/debugadapter/debugger/python/pythondebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <QApplication>
#include <QDir>

#include "unistd.h"

class PythonDebuggerPrivate {
friend class PythonDebugger;
QProcess process;
Expand Down Expand Up @@ -98,25 +100,26 @@ void PythonDebugger::initialize(const QString &pythonExecute,
QString logFolder = projectCachePath + "/dap/pylog";
QString param = pythonExecute + " -m debugpy --listen " + validPort +
" --wait-for-client --log-to " + logFolder + " " + fileName + " --pid " + pid;
qInfo() << param;

QStringList options;
options << "-c" << param;
d->process.start("/bin/bash", options);
d->process.waitForStarted();
}

void PythonDebugger::slotReceiveClientInfo(const QString &uuid,
void PythonDebugger::slotReceiveClientInfo(const QString &ppid,
const QString &kit,
const QString &pythonExecute,
const QString &fileName,
const QString &projectPath,
const QString &projectCachePath)
{
if (ppid != getppid())
return;
d->port = 0;
d->process.close();
initialize(pythonExecute, fileName, projectCachePath);
emit sigSendToClient(uuid, d->port, kit, projectPath);
emit sigSendToClient(ppid, d->port, kit, projectPath);
}


4 changes: 2 additions & 2 deletions src/tools/debugadapter/debugger/python/pythondebugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class PythonDebugger : public QObject
virtual ~PythonDebugger() override;

signals:
void sigSendToClient(const QString &uuid, int port, const QString &kit, const QString &projectPath);
void sigSendToClient(const QString &ppid, int port, const QString &kit, const QString &projectPath);

public slots:
void slotReceiveClientInfo(const QString &uuid,
void slotReceiveClientInfo(const QString &ppid,
const QString &kit,
const QString &pythonExecute,
const QString &fileName,
Expand Down

0 comments on commit 1f47bc9

Please sign in to comment.