[solved] QCAD conversions cannot be executed concurrently

Please use this forum to post feedback and suggestions related to QCAD.

Moderator: andrew

Post Reply
horstr
Newbie Member
Posts: 4
Joined: Wed May 02, 2018 11:06 am

[solved] QCAD conversions cannot be executed concurrently

Post by horstr » Thu May 03, 2018 3:33 pm

We use QCAD Professional for converting DWG/DXF files to PDF. Unfortunately, the single-instance check does not allow concurrent execution of the software. The issue can be reproduced as follows:

Script (Bash, tested on Linux):

Code: Select all

for i in {0..1}; do
  ./qcad -no-gui -autostart scripts/Pro/Tools/Dwg2Pdf/Dwg2Pdf.js dwg2pdf -a -f -platform offscreen -o test.pdf test${i}.dwg &
done
wait
Output:

Code: Select all

QCAD version  3.19.2
QCAD version  3.19.2
10:46:41: Debug:    RDwgPlugin::init
10:46:41: Debug:    RDxfPlugin::init
10:46:41: Debug:    RHelpPlugin::init
10:46:41: Debug:    RPolygonPlugin::init
10:46:41: Debug:    RProScriptsPlugin::init
10:46:41: Debug:    RTriangulationPlugin::init
10:46:42: Debug:    calling odInitialize
10:46:44: Debug:    dim style "ISO-25"
Warning:  Application already running. Aborting...
Converting
  from: test.dwg
  to  : test0.pdf
  
The single-instance check should be disabled for conversions to enable concurrent execution. Would you be open to that kind of change?
If I bypass the single-instance check using SELinux (for testing purposes), concurrent conversions work as expected.

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: QCAD conversions cannot be executed concurrently

Post by andrew » Thu May 03, 2018 3:38 pm

Is there a reason you are not using the supplied command line tool dwg2pdf? I.e:

./dwg2pdf -a -f -platform offscreen -o test.pdf test${i}.dwg

All command line tool scripts allow concurrent execution (using the QCAD command line switch -allow-multiple-instances).

See also QCAD usage info (qcad -h):

Code: Select all

Usage: qcad [Options] [Files to open]

-allow-multiple-instances        Don't try to avoid multiple instances from running simultaneously.

horstr
Newbie Member
Posts: 4
Joined: Wed May 02, 2018 11:06 am

Re: QCAD conversions cannot be executed concurrently

Post by horstr » Wed May 09, 2018 1:50 pm

Thanks for the info! We don't use the provided scripts directly because we need a single command line for Windows and Linux and the way we execute qcad (CreateProcess) does not support the use of batch files. Furthermore, the Windows version logs to %TEMP% which is not what we want to happen in production. Also, I'm pretty sure this breaks multiple instances due to file sharing violations caused by sharing the log file:

Code: Select all

notepad 1>log 2>&1
notepad 1>log 2>&1
The process cannot access the file because it is being used by another process.
In older versions of QCAD, the Windows scripts did not use -allow-multiple-instances, that's why we missed the switch.

horstr
Newbie Member
Posts: 4
Joined: Wed May 02, 2018 11:06 am

Re: [solved] QCAD conversions cannot be executed concurrently

Post by horstr » Wed May 09, 2018 3:43 pm

Can you confirm the concurrency issue in case of dwg2pdf on Windows caused by the log? This would be beneficial for all users as well us should we ever manage to use the scripts directly. As for the log: why is the log needed at all in comparison to Linux? Logs that grow indefinitely are usually problematic in production.

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: [solved] QCAD conversions cannot be executed concurrently

Post by andrew » Wed May 09, 2018 3:53 pm

horstr wrote:Can you confirm the concurrency issue in case of dwg2pdf on Windows caused by the log?
Yes, this can be an issue.
horstr wrote:As for the log: why is the log needed at all in comparison to Linux? Logs that grow indefinitely are usually problematic in production.
The log should not grow as it is overwritten on each run. You can easily disable logging in the batch file by streaming all output to NUL (>NUL). However, logs can be helpful for debugging. The log file is necessary under Windows because Windows applications are restricted to be either GUI applications or console applications but never both. I.e. QCAD cannot write to the console it was started from like under macOS/Linux.

horstr
Newbie Member
Posts: 4
Joined: Wed May 02, 2018 11:06 am

Re: [solved] QCAD conversions cannot be executed concurrently

Post by horstr » Wed May 09, 2018 4:22 pm

Thanks, you're right. I missed the missing append (> vs. >>). We'd prefer not having to tell our customers to modify a third-party application - even if it's just a batch script. A workaround for the GUI/non-GUI issue is providing two executables (one GUI, one non-GUI) that effectively run the same code.

Post Reply

Return to “QCAD Suggestions and Feedback”