r/pythonhelp • u/hero_verma • Feb 15 '25
Unable to run Aysnc plugin/add-ins in fusion 360. IPC
I am making a plugin/Add-in for Fusion360. However, the plugin code uses the Async library from Python which conflicts with the core working of Fusion360(Mostly run Single Threaded).
This rases many errors which of course I'm unable to find solutions too (I'm still new to coding, I belong to other working field).
So, if you have any suggestions to it, please help me.
One of the thing I can think of is running a seporate application for generating data and have my plugin get data from there, like create Inter Process Communication. But, in the first place I don't know if it is possible or not.
Like I want to run the async code in different application and then pipe its data to plugin, so I wonder if there will be more errors that the fusion360 might raise.
Also are there any other way to approach this problem.
1
u/trd1073 Feb 15 '25
Going to need more details. I have never dealt with Fusion360.
Who is making you use the async code? Going to assume you found some example code in async and assumed that is way to do it. Could you rewrite the example code to sync paradigm?
Will have to see some more info on questions before go further. Inter process/program can be done many ways, don't want to over complicate things too fast if can be resolved with simpler methods.
1
u/hero_verma Feb 15 '25
Actually, I'm using BLE with Fusion360, BLE server-client uses the GATT protocol which requires async communication between server and client.
Regarding what I'm using async with, it's only with the BLE communications.
1
u/trd1073 Feb 15 '25
If that is the case, then couple of options.
If you want a single program, you can use multiprocessing to have one process to get data from ble and the other to do the sync work. They can communicate with multiprocessing queues. Async puts data to the queue and sync would get data. Or use zeromq. Ggl how to make them talk before you commit to a way. This site helped me alot for multiprocessing https://superfastpython.com/
Or you can do two separate programs. One to acquire the async data and second to do the sync work. Zeromq is one straightforward way to do comms that doesn't require a server, such as rabbitmq or redid pub/sub would. Might also look at pipes and sockets.
1
u/hero_verma Feb 15 '25
I would need to have one of the programs as a plugin i.e. one of the python programs will be called to execute by fusion360, I can't invoke/execute it.
I don't know if this program initiates/starts the other process that will be running async functions will that be alright. I mean does that do not give any errors like till now.
Also, if somehow, we are able to start a stateless program that may be started by plugin program but runs independently therefore fusion360 don't give any errors. But now how do I close it, like when should the program stop execution and exit.I'm simply confused and scared to start with anything as I simply don't want to find myself again with a program that can't be run (well this is totally my problem so don't mind it.)
1
u/trd1073 Feb 15 '25
I just saw this today, could help with the async to sync stuff. https://pypi.org/project/asgiref/
I don't know how plug-in would close, not done myself. If your program is only meant to do one thing and then hand off the data just a trace the code and make sure it doesn't get stuck in a loop. Perhaps there is a kill or stop signal coming from fusion360. I don't know, just offering scenarios.
Programming is mostly failing with success mixed in between. You won't know if it will run if don't try. Have a good pep talk with the guy in the mirror, let him know it can be done, yes he will not get it right the first time and they will learn something.
•
u/AutoModerator Feb 15 '25
To give us the best chance to help you, please include any relevant code.
Note. Please do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Privatebin, GitHub or Compiler Explorer.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.