Git Product home page Git Product logo

Comments (5)

pbek avatar pbek commented on September 6, 2024

Seems like https://doc.qt.io/qt-6/qprocess.html#startDetached-1 has a timeout in

/**
* Starts an executable detached with parameters
*
* @param executablePath the path of the executable
* @param parameters a list of parameter strings
* @param workingDirectory the directory to run the executable from (optional)
* @return true on success, false otherwise
*/
bool Utils::Misc::startDetachedProcess(const QString &executablePath, const QStringList &parameters,
QString workingDirectory) {
QProcess process;
if (workingDirectory.isEmpty()) {
// set the directory to run the executable from
// process.setWorkingDirectory() doesn't seem
// to do anything under Windows
workingDirectory = QCoreApplication::applicationDirPath();
}
// start executablePath detached with parameters
#ifdef Q_OS_MAC
return process.startDetached(QStringLiteral("open"),
QStringList() << executablePath << "--args" << parameters,
workingDirectory);
#else
return process.startDetached(executablePath, parameters, workingDirectory);
#endif
}

But it doesn't look that you can get around that easily...
But I also don't think it's a good idea to run processes from QOwnNotes in the background indefinitely...

What did you try to do with https://git.sad.ovh/sophie/QOwnNotesDiscordRPC/src/branch/main/main.py?

from qownnotes.

fucksophie avatar fucksophie commented on September 6, 2024

Seems like https://doc.qt.io/qt-6/qprocess.html#startDetached-1 has a timeout in

/**
* Starts an executable detached with parameters
*
* @param executablePath the path of the executable
* @param parameters a list of parameter strings
* @param workingDirectory the directory to run the executable from (optional)
* @return true on success, false otherwise
*/
bool Utils::Misc::startDetachedProcess(const QString &executablePath, const QStringList &parameters,
QString workingDirectory) {
QProcess process;
if (workingDirectory.isEmpty()) {
// set the directory to run the executable from
// process.setWorkingDirectory() doesn't seem
// to do anything under Windows
workingDirectory = QCoreApplication::applicationDirPath();
}
// start executablePath detached with parameters
#ifdef Q_OS_MAC
return process.startDetached(QStringLiteral("open"),
QStringList() << executablePath << "--args" << parameters,
workingDirectory);
#else
return process.startDetached(executablePath, parameters, workingDirectory);
#endif
}

But it doesn't look that you can get around that easily... But I also don't think it's a good idea to run processes from QOwnNotes in the background indefinitely...

What did you try to do with https://git.sad.ovh/sophie/QOwnNotesDiscordRPC/src/branch/main/main.py?

In short, I wanted to add Discord RPC to QOwnNotes. This requres a pretty complicated protocol and from what I know QML does not have a good binary writing and protocol making library (also, because I'm lazy.. who isn't? xD)

I've succeeded in this (however, it's quite buggy, due to this issue). The QML and python scripts manage state through a websocket.

  1. QML starts Python
  2. Python closes if already open
  3. QML connects websocket to python
  4. Python sends data
  5. If no connection in 5s, python closes script

from qownnotes.

pbek avatar pbek commented on September 6, 2024

https://git.sad.ovh/sophie/QOwnNotesDiscordRPC/src/branch/main/main.qml

Nifty, websocket in QML 😉👍️

Hm, things you maybe could do...

  • Find out if you can increase the timeout for QProcess, then I could add that feature
  • Run your Python script periodically and do polling in your Python script (or do you need bidirectional communication between Discord and your Script?)
  • Start your python script as system d service?

from qownnotes.

Waqar144 avatar Waqar144 commented on September 6, 2024

There is no timeout in QProcess::startDetached, it is mostly likely an issue in the python script you are launching. Try running a program with infinite loop and see if it stops after 30 seconds.

from qownnotes.

pbek avatar pbek commented on September 6, 2024

Ah, good insight! I hardly ever use Python. 😁

from qownnotes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.