Multi-threaded development #218
Replies: 1 comment 3 replies
-
1, Please check that this is not a violation of the AutoCAD EULA, pretty sure it is, my answers may be limited as not to put my ADN membership at risk Hypothetically, you could have a long running thread that handles the network traffic. This thread adds commands to a queue. I think this approach could potentially have a lot of flaws, especially when it comes to undo, erase, etc. 2, there’s a sample for debugging, testPyRxDebug.py and some notes here https://www.theswamp.org/index.php?topic=58821 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently developing a plugin that allows for concurrent editing of CAD databases between multiple users. The current component I'm working on listens to events (object modified, object appended) and sends those logs to a server.
My first approach was to just send the proper log synchronously once the event was triggered. However, it would look like this.
My second approach was to use a background process that sent the logs using http. It looked something like this
queue.Queue()
This removed rendering delay on the user end! However, sending the logs synchronously was really slow. Using httpx, async, or a WebSocket also crashed the background process.
Instead of waiting for each http request to finish one at a time, I'll bunch the 6 http requests into 1!
So, I'll take each JSON log
{"event_type": log.event_type, "object_id": log.object_id}
And append it to a list!
Which will be sent to the server.
However, it seems that the list data type is giving me some issues that may have to do with it's lack of thread safety. I'm not sure what the exact issue is, so I'd appreciate better documentation on how to debug. I will be opening an issue.
I also noticed that @CEXT-Dan's samples that concern multithreading did not include the list data type. I think that if possible, creating a sample that uses the list data type would be a great reference.
Beta Was this translation helpful? Give feedback.
All reactions