QOwnNotes
QOwnNotes copied to clipboard
[BUG] startDetachedProcess dies after about 30 seconds
Expected behaviour
for startDetachedProcess in the scripting API to run a entierly seperate process
Actual behaviour
startDetachedProcess dies after about 30 seconds
Steps to reproduce
- Create a startDetachedProcess that, for example, writes to a file every second.
- Watch it stop writing and hit
onDetachedProcessCallbackin 29 or 30 seconds.
Exact code uses a python script and QML. https://git.sad.ovh/sophie/QOwnNotesDiscordRPC
Output from the debug section in the settings dialog
Expand
QOwnNotes Debug Information
General Info
Current Date: Sat Aug 3 03:29:54 2024
Version: 24.8.1
Build date: Aug 1 2024
Build number: 1116
Platform: linux (wayland)
Operating System: Arch Linux
Build architecture: x86_64
Current architecture: x86_64
Release: AUR
Qt Version (build): 5.15.14
Qt Version (runtime): 5.15.14
Portable mode: no
Settings path / key: /home/yf/.config/PBE/QOwnNotes.conf
Application database path: /home/yf/.local/share/PBE/QOwnNotes/QOwnNotes.sqlite
Application arguments: QOwnNotes
Qt Debug: 0
Locale (system): en_US
Locale (interface): en
Primary screen resolution: 1920x1080
Screen resolution(s): 1920x1080, 1920x1080
Icon theme: breeze-dark-qownnotes
Notes in current note folder: 27
Calendar items: 0
Enabled scripts: 3
Database drivers: QIBASE, QSQLITE, QMARIADB, QMYSQL, QMYSQL3, QODBC, QODBC3, QPSQL, QPSQL7, QTDS, QTDS7
Server Info
serverUrl: empty
appIsValid: no
notesPathExists: empty
connectionErrorMessage: empty
Spellchecking
Enabled: false
Selected language: empty
Language codes: empty
Language names: empty
Application dictionaries path: /home/yf/.local/share/PBE/QOwnNotes/dicts
Note folders
currentNoteFolderId: 1
Note folder default
id: 1
isCurrent: yes
activeTagId: 0
localPath: /home/yf/EncryptedSync/notes
remotePath: Notes
cloudConnectionId: 1
isShowSubfolders: yes
isUseGit: no
allowDifferentNoteFileName: yes
activeNoteSubFolder name: Expense tracking
database file: /home/yf/EncryptedSync/notes/notes.sqlite
Cloud connections
Cloud connection Noklusējums
id: 1
isCurrent: yes
serverUrl: empty
username: empty
accountId: empty
Enabled scripts
Script AI Text Tool
id: 1
path: /home/yf/.local/share/PBE/QOwnNotes/scripts/ai-text-tool/ai-text-tool.qml
variablesJson: empty
identifier: ai-text-tool
version: 0.1.0
minAppVersion: 24.5.7
Script AI Autocompletion
id: 2
path: /home/yf/.local/share/PBE/QOwnNotes/scripts/ai-autocompletion/ai-autocompletion.qml
variablesJson: empty
identifier: ai-autocompletion
version: 0.0.1
minAppVersion: 24.5.3
Script main
id: 4
path: /home/yf/QOwnNotesDiscordRPC/main.qml
variablesJson: empty
Settings
AboutDialog/geometry (QByteArray): <binary data>
ActiveNoteHistoryItem (NoteHistoryItem): <binary data>
Debug/fakeOldVersionNumber (QString): false
Debug/fileLogging (QString): false
Editor/CurrentSchemaKey (QString): EditorColorSchema-6033d61b-cb96-46d5-a3a8-20d5172017eb
Editor/autoBracketClosing (QString): true
Editor/autoBracketRemoval (QString): true
Editor/disableCursorBlinking (QString): false
Editor/editorWidthInDFMOnly (QString): true
Editor/highlightCurrentLine (QString): true
Editor/indentSize (QString): 4
Editor/removeTrailingSpaces (QString): false
Editor/showLineNumbers (QString): false
Editor/useTabIndent (QString): false
Editor/vimMode (QString): false
FileDialog/LastPath (QString): /home/yf/QOwnNotesDiscordRPC
FileDialog/LastPath-ScriptPath (QString): /home/yf/QOwnNotesDiscordRPC
ImageDialog/disableCopying (QString): false
ImageDialog/geometry (QByteArray): <binary data>
LastUpdateCheck (QDateTime): 2024-08-03T03:19:54.981
LocalTrashDialog/geometry (QByteArray): <binary data>
MainWindow/geometry (QByteArray): <binary data>
MainWindow/mainToolBar.iconSize (QString): 24
MainWindow/menuBarGeometry (QByteArray): <binary data>
MainWindow/noteSubFolderTreeWidgetExpandState-1 (QStringList): misc
MainWindow/noteTextEdit.code.font (QString): monospace,13,-1,2,50,0,0,0,0,0
MainWindow/noteTextEdit.font (QString): Sans Serif,13,-1,5,50,0,0,0,0,0
MainWindow/noteTextView.code.font (QString): monospace,9,-1,2,50,0,0,0,0,0
MainWindow/noteTextView.font (QString): Sans Serif,9,-1,5,50,0,0,0,0,0
MainWindow/noteTextView.ignoreCodeFontSize (QString): true
MainWindow/noteTextView.refreshDebounceTime (QString): 600
MainWindow/noteTextView.rtl (QString): false
MainWindow/noteTextView.underline (QString): true
MainWindow/noteTextView.useEditorStyles (QString): true
MainWindow/noteTextView.useInternalExportStyling (QString): true
MainWindow/showNotesFromAllNoteSubFolders (QString): false
MessageBoxOverride/remove-notes (QString): 16384
NoteFolder-1/NoteTabNameList (QStringList): Camera (python), syncthing.md, Note 2024-04-15T19.38.29, servermaint.md, August expense tracking, buildsystem.md, fluidsim.md, watch.md, rpi.md
NoteFolder-1/NoteTabStickinessList (QString): 0
NoteFolder-1/NoteTabSubFolderPathDataList (QStringList): code, blog, , blog, Expense tracking , blog, blog, blog, blog
NoteFolder-1/allowDifferentNoteFileName (bool): true
NoteHistory-1 (QVariantList): <variant list with 69 item(s)>
NoteHistoryCurrentIndex-1 (QString): 68
PiwikClientId (QString): <hidden>
ScriptRepositoryDialog/geometry (QByteArray): <binary data>
ScriptRepositoryDialog/mainSplitterState (QByteArray): <binary data>
SearchEngineId (QString): 2
SettingsDialog/geometry (QByteArray): <binary data>
SettingsDialog/mainSplitterState (QByteArray): <binary data>
ShowSystemTray (QString): false
StartHidden (QString): false
TableDialog/geometry (QByteArray): <binary data>
UpdateDialog/geometry (QByteArray): <binary data>
WelcomeDialog/geometry (QByteArray): <binary data>
acceptAllExternalModifications (QString): false
ai/currentBackend (QString): groq
ai/enabled (QString): true
ai/groq/apiKey (QString): <hidden>
ai/groq/currentModel (QString): llama3-70b-8192
ai/ollama/currentModel (QString): mistral:latest
ai/openai/apiKey (QString): <hidden>
allowNoteEditing (bool): true
allowOnlyOneAppInstance (QString): true
appMetrics/disableAppHeartbeat (QString): false
appMetrics/disableTracking (QString): false
appMetrics/notificationShown (QString): true
autoReadOnlyMode (QString): false
autoReadOnlyModeTimeout (QString): 30
automaticNoteFolderDatabaseClosing (QString): false
checkSpelling (bool): false
closeTodoListAfterSave (QString): false
cryptoKey (QString): <hidden>
currentNoteFolderId (QString): 1
currentWorkspace (QString): initial
cursorWidth (QString): 1
darkMode (QString): false
darkModeColors (QString): true
darkModeIconTheme (QString): true
darkModeTrayIcon (QString): false
defaultNoteFileExtension (QString): md
demoNotesCreated (QString): true
disableAutomaticUpdateDialog (QString): true
disableSavedSearchesAutoCompletion (QString): false
dockWasInitializedOnce (QString): true
enableNoteTree (QString): false
enableSocketServer (QString): true
enableWebAppSupport (QString): false
externalEditorPath (QString): empty
fullyHighlightedBlockquotes (QString): false
gitCommitInterval (QString): 30
gitExecutablePath (QString): empty
gitLogCommand (QString): empty
guiFirstRunInit (bool): true
ignoreAllExternalModifications (QString): false
ignoreAllExternalNoteFolderChanges (QString): false
ignoreNoteSubFolders (QString): ^\.
ignoredNoteFiles (QString): empty
imageScaleDown (QString): false
imageScaleDownMaximumHeight (QString): 1024
imageScaleDownMaximumWidth (QString): 1024
initialLayoutIdentifier (QString): minimal
insertTimeFormat (QString): empty
interfaceFontSize (QString): 11
interfaceLanguage (QString): en
internalIconTheme (QString): false
itemHeight (QString): 17
legacyLinking (QString): false
localTrash/autoCleanupDays (QString): 30
localTrash/autoCleanupEnabled (QString): true
localTrash/supportEnabled (QString): true
localTrashSplitterSizes (QByteArray): <binary data>
markdownHighlightingEnabled (QString): true
navigationPanelAutoSelect (QString): true
navigationPanelHideSearch (QString): false
networking/ignoreSSLErrors (QString): true
networking/proxyType (QString): 2
newNoteAskHeadline (QString): false
noteEditIsCentralWidget (QString): true
noteFileExtensionList (QStringList): md, txt
noteListPreview (QString): false
noteSaveIntervalTime (QString): 10
noteSubfoldersPanelDisplayAsFullTree (QString): true
noteSubfoldersPanelHideSearch (QString): false
noteSubfoldersPanelOrder (QString): 0
noteSubfoldersPanelShowFullPath (QString): false
noteSubfoldersPanelShowNotesRecursively (QString): false
noteSubfoldersPanelShowRootFolderName (QString): true
noteSubfoldersPanelSort (QString): 0
noteSubfoldersPanelTabsUnsetAllNotesSelection (QString): false
notesPanelOrder (QString): 0
notesPanelSort (QString): 1
notesPath (QString): /home/yf/EncryptedSync/notes
notifyAllExternalModifications (QString): false
overrideInterfaceFontSize (QString): false
ownCloud/supportEnabled (QString): false
ownCloud/todoCalendarBackend (QString): 3
ownCloud/todoCalendarCalDAVPassword (QString): <hidden>
ownCloud/todoCalendarCalDAVServerUrl (QString): empty
ownCloud/todoCalendarCalDAVUsername (QString): empty
ownCloud/todoCalendarCloudConnectionId (QString): 1
ownCloud/todoCalendarDisplayNameList: empty
ownCloud/todoCalendarEnabledList: empty
ownCloud/todoCalendarEnabledUrlList: empty
ownCloud/todoCalendarUrlList: empty
ownCloudInfo/appIsValid (bool): false
ownCloudInfo/connectionErrorMessage (QString): empty
ownCloudInfo/notesPathExistsText (QString): empty
ownCloudInfo/serverVersion (QString): empty
restoreCursorPosition (QString): true
restoreLastNoteAtStartup (QString): true
restoreNoteTabs (QString): true
savedSearches/noteFolder-1 (QStringList): Note 2024-08-03T03.29.47, Note 2024-08-03T03.29.46, Note 2024-08-02T14.59.49, Note 2024-08-01T23.55.11, Note 2024-07-30T16.19.06, Note 2024-07-24T01.03.18, Note 2024-07-24T00.07.03, a, Note 2024-06-09T12.21.54, Note 2024-04-25T16.07.49, Note 2024-04-19T16.27.47, Note 2024-04-07T15.11.49, Note 2024-04-01T10.16.58, Note 2024-04-01T10.10.19, Note 2024-03-31T22.20.28, Note 2024-03-30T18.21.47, Note 2024-03-30T16.14.33, Note 2024-03-30T16.13.53, Note 2024-03-30T16.13.26, Note 2024-03-30T16.12.04, Note 2024-03-30T16.10.39, Note 2024-03-30T16.10.11, Note 2024-03-30T16.07.59, Note 2024-03-30T16.07.20, Note 2024-03-30T16.06.53, Note 2024-03-30T16.06.31, Note 2024-03-30T16.04.06, Note 2024-03-30T16.04.03, Note 2024-03-30T16.01.53, Note 2024-03-30T16.01.47
showMatches (QString): true
showMenuBar (bool): true
showStatusBar (bool): true
showStatusBarNotePath (QString): true
showStatusBarRelativeNotePath (QString): false
startInReadOnlyMode (QString): false
systemIconTheme (QString): false
taggingShowNotesRecursively (QString): false
tagsPanelHideNoteCount (QString): false
tagsPanelHideSearch (QString): false
tagsPanelOrder (QString): 0
tagsPanelSort (QString): 0
todoCalendarSupport (QString): true
toolbar/1/items (QStringList): action_New_note, action_Find_note, action_Remove_note, action_Open_note_in_external_editor, actionShow_local_trash, actionAllow_note_editing, , action_Back_in_note_history, action_Forward_in_note_history, , action_Find_text_in_note, actionReplace_in_current_note, , actionShow_versions, actionShow_trash, actionShare_note, , actionShow_Todo_List
toolbar/1/name (QString): mainToolBar
toolbar/1/title (QString): main toolbar
toolbar/2/items (QStringList): actionFormat_text_bold, actionFormat_text_italic, actionStrike_out_text, actionInsert_code_block, actionInsert_block_quote
toolbar/2/name (QString): formattingToolbar
toolbar/2/title (QString): formatting toolbar
toolbar/3/items (QStringList): actionInsert_text_link, actionInsert_image, actionInsert_current_time
toolbar/3/name (QString): insertingToolbar
toolbar/3/title (QString): inserting toolbar
toolbar/4/items (QStringList): action_Encrypt_note, actionEdit_encrypted_note, actionDecrypt_note
toolbar/4/name (QString): encryptionToolbar
toolbar/4/title (QString): encryption toolbar
toolbar/5/items (QStringList): actionEnable_AI, actionAiBackendComboBox, actionAiModelComboBox
toolbar/5/name (QString): aiToolbar
toolbar/5/title (QString): AI toolbar
toolbar/6/items (QStringList): actionWorkspaceComboBox, actionStore_as_new_workspace, actionRemove_current_workspace, actionRename_current_workspace, actionSwitch_to_previous_workspace, actionUnlock_panels, , actionToggle_distraction_free_mode, action_Increase_note_text_size, action_Decrease_note_text_size, action_Reset_note_text_size
toolbar/6/name (QString): windowToolbar
toolbar/6/title (QString): window toolbar
toolbar/7/items (QString): action_Quit
toolbar/7/name (QString): quitToolbar
toolbar/7/title (QString): quit toolbar
toolbar/size (QString): 7
useNoteFolderButtons (QString): false
useUNIXNewline (QString): false
webAppClientService/serverUrl (QString): wss://app.qownnotes.org
webAppClientService/token (QString): <hidden>
webSocketServerService/bookmarksNoteName (QString): Bookmarks
webSocketServerService/bookmarksTag (QString): bookmarks
webSocketServerService/commandSnippetsNoteName (QString): Commands
webSocketServerService/commandSnippetsTag (QString): commands
webSocketServerService/port (QString): 22222
workspace-initial/name (QString): Minimāls
workspace-initial/noteSubFolderDockWidgetVisible (QString): true
workspace-initial/windowState (QByteArray): <binary data>
workspaces (QString): initial
System environment
SHELL: /bin/nu
HYPRLAND_CMD: Hyprland
CSF_MDTVTexturesDirectory: /usr/share/opencascade/resources/Textures
XDG_CONFIG_DIRS: /etc/xdg
XDG_BACKEND: wayland
CSF_DrawPluginDefaults: /usr/share/opencascade/resources/DrawResources
CSF_LANGUAGE: us
CSF_MIGRATION_TYPES: /usr/share/opencascade/resources/StdResource/MigrationSheet.txt
XDG_DATA_HOME: /home/yf/.local/share
GRADLE_HOME: /usr/share/java/gradle
XDG_CONFIG_HOME: /home/yf/.config
MEMORY_PRESSURE_WRITE: c29tZSAyMDAwMDAgMjAwMDAwMAA=
HL_INITIAL_WORKSPACE_TOKEN: f31eb1d3-fac7-4539-9c9a-bbce3809c27e
CSF_OCCTResourcePath: /usr/share/opencascade/resources
XCURSOR_SIZE: 24
CSF_STEPDefaults: /usr/share/opencascade/resources/XSTEPResource
XDG_SEAT: seat0
PWD: /home/yf
LOGNAME: yf
XDG_SESSION_TYPE: wayland
DRAWHOME: /usr/share/opencascade/resources/DrawResources
SYSTEMD_EXEC_PID: 924
_: /usr/bin/rofi
CSF_StandardLiteDefaults: /usr/share/opencascade/resources/StdResource
MOTD_SHOWN: pam
HOME: /home/yf
LANG: en_US.UTF-8
_JAVA_AWT_WM_NONREPARENTING: 1
XDG_CURRENT_DESKTOP: Hyprland
MEMORY_PRESSURE_WATCH: /sys/fs/cgroup/system.slice/lemurs.service/memory.pressure
WAYLAND_DISPLAY: wayland-1
INVOCATION_ID: eb69f6f3832c4a9eabcf545cdf2d11cb
CSF_ShadersDirectory: /usr/share/opencascade/resources/Shaders
CSF_EXCEPTION_PROMPT: 1
CSF_XmlOcafResource: /usr/share/opencascade/resources/XmlOcafResource
XDG_CACHE_HOME: /home/yf/.cache
CSF_SHMessage: /usr/share/opencascade/resources/SHMessage
XDG_SESSION_CLASS: user
TERM: linux
USER: yf
CSF_StandardDefaults: /usr/share/opencascade/resources/StdResource
CSF_IGESDefaults: /usr/share/opencascade/resources/XSTEPResource
HYPRLAND_INSTANCE_SIGNATURE: 918d8340afd652b011b937d29d5eea0be08467f5_1722628069_198413616
DISPLAY: :0
CSF_XCAFDefaults: /usr/share/opencascade/resources/StdResource
SHLVL: 0
MOZ_ENABLE_WAYLAND: 1
XDG_VTNR: 2
CSF_PluginDefaults: /usr/share/opencascade/resources/StdResource
CSF_TObjMessage: /usr/share/opencascade/resources/TObj
XDG_SESSION_ID: c1
CASROOT: /usr
XDG_STATE_HOME: /home/yf/.local/state
XDG_RUNTIME_DIR: /run/user/1000
HAXE_STD_PATH: /usr/share/haxe/std
DEBUGINFOD_URLS: https://debuginfod.archlinux.org
CSF_XSMessage: /usr/share/opencascade/resources/XSMessage
MMGT_CLEAR: 1
XDG_DATA_DIRS: /var/lib/flatpak/exports/share:/home/yf/.local/share/flatpak/exports/share:/usr/share:/usr/local/share
PATH: /usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/emscripten:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/opt/rocm/bin:/usr/lib/rustup/bin
CSF_TObjDefaults: /usr/share/opencascade/resources/StdResource
DBUS_SESSION_BUS_ADDRESS: unix:path=/run/user/1000/bus
HG: /usr/bin/hg
MAIL: /var/spool/mail/yf
DRAWDEFAULT: /usr/share/opencascade/resources/DrawResources/DrawDefault
Relevant log output in the Log panel
Expand
[03:26:13] [scripting] Open! [03:26:14] [scripting] true [03:26:15] [scripting] true [03:26:16] [scripting] true [03:26:17] [scripting] true [03:26:18] [scripting] true [03:26:19] [scripting] true [03:26:20] [scripting] true [03:26:21] [scripting] true [03:26:22] [scripting] true [03:26:23] [scripting] true [03:26:24] [scripting] true [03:26:25] [scripting] true [03:26:26] [scripting] true [03:26:27] [scripting] true [03:26:28] [scripting] true [03:26:29] [scripting] true [03:26:30] [scripting] true [03:26:31] [scripting] true [03:26:32] [scripting] true [03:26:33] [scripting] true [03:26:34] [scripting] true [03:26:35] [scripting] true [03:26:36] [scripting] true [03:26:37] [scripting] true [03:26:38] [scripting] true [03:26:38] [scripting] Error: The remote host closed the connection [03:26:38] [scripting] Socket closed
Seems like https://doc.qt.io/qt-6/qprocess.html#startDetached-1 has a timeout in
https://github.com/pbek/QOwnNotes/blob/e915cfc6b15cb7697127928fa265df5decdd4afd/src/utils/misc.cpp#L343-L370
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?
Seems like https://doc.qt.io/qt-6/qprocess.html#startDetached-1 has a timeout in
https://github.com/pbek/QOwnNotes/blob/e915cfc6b15cb7697127928fa265df5decdd4afd/src/utils/misc.cpp#L343-L370
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.
- QML starts Python
- Python closes if already open
- QML connects websocket to python
- Python sends data
- If no connection in 5s, python closes script
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?
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.
Ah, good insight! I hardly ever use Python. 😁
This issue is stale because it has been open for 30 days with no activity.
Most likely my Python script.. This just fixed itself after a couple revisions to the python script.
Great 😉