- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Autodesk community,
Description:
In this post i am describing a situation where the IMPORT command simply hangs.
The IMPORT command hangs when it is issued (within a short period of time) from multiple instances of acCoreConsole.
(This is a separate behaviour from the bug I described here and for which Autodesk reported that they have provided a fix for in AutoCAD 2020).
I would like to stress that IMPORT does NOT fail at all for the exact same files if acCoreConsole is run sequentially, looping through and IMPORTing each file one by one. -- it fails when two or more instances of acCoreConsole are run in parallel and each calls IMPORT on their respective files (different files!!).
How to reproduce:
1) Write a script to launch 2 or more parallel processes (c# Diagnostics.Process.Start) of accoreconsole where each instance issues IMPORT with a <unique_filename.iam> then issues a SAVEAS with a <unique_filename.dwg>
2) Have the script iterate over a statistically significant number of files - say 20 to 50 .iam files - so that chances of a collision increase.
3) Note that accoreconsole.exe will hang when 2 or more instances issue their IMPORT commands at similar times. (within a few seconds on my machine). You will see that it hangs during the IMPORT command (if you run with the console window visible you will see the IMPORT command writes progress dots "..." for ever until you kill the process).
Workaround:
I suspect that the IMPORT command might be failing due to some internal race or deadlock condition on some resource that it uses.
My workaround is therefore to prevent multiple instances of Core Console from issuing the IMPORT command at a similar time. In my project the way I have achieved this is to ensure each instance calls Process.Start() inside a lock that includes a delay as follows:
lock (MyPadlock) { // launch this instance of acCoreConsole p.Start(); // wait a little while before releasing the lock to ensure other acCoreConsole instances are
// suitably staggered to prevent internal deadlocking on the same resource
// say, acTranslators.exe perhaps. int milliseconds = 5000; // 5 seconds Thread.Sleep(milliseconds); }
The question is how long a delay is sufficient - and i guess the answer to that depends on how fast a computer you are running it on.
I have experimented with the time period and find that on my machine if i lock other instances from starting for 5 seconds then i get no failures at all.
However, if I reduce the time period to 3 seconds i begin to get some failures now and then.
If i reduce the time period to ZERO then I find that every thread fails except for the first thread to start.
I'd appreciate feedback on this - especially if you cannot reproduce the behaviour
regards
Dan
Atkins Consultants Ltd UK
+19,000 staff (M&E, Civils, Structural, Geotechnical, Environmental and more)
Solved! Go to Solution.