Replies: 1 comment 1 reply
-
Hi @scdanya , Thank you for the encouragement! Using multithreading in DynamicMacros is an interesting idea. I'll have to look more into this. With the current way DynamicMacros and Klipper is structured, you can display messages to the console by pasting this into a Python file: import threading
print('Hello before')
t = threading.Thread(target=print, args=('Hello from thread',))
t.run()
print('Hello after') and using It is possible to run G-Code commands from threads, like in this example: import threading
print('Hello before')
t = threading.Thread(target=gcode, args=('M109 S200',))
t.run()
print('Hello after') However, this will not print To get around the issue with G-Code, some commands may be able to run by directly accessing Klipper's internal API or by clever use of the Python |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! I'd like to express my huge gratitude for your work, a great solution for running Python scripts that contain G-code.
Everything works perfectly if I call a single G-code or multiple G-codes sequentially in a Python script. However, I have a question!
Is it possible to run a macro that calls a Python script that uses the threading library (or any other library for parallelism)? In my project, this is necessary for running multiple G-codes in parallel (the macro contents are different - from processing sensors to running stepper motors).
Yes, I know that Klipper does not support this format by default, but here we are in the realm of Python scripts, where threading is often used to perform processes in parallel, so I thought of a similar implementation.
I've already tried writing a small Python script that calls two macros in parallel, simply printing two phrases to the Klipper console. Klipper doesn't complain about the code, the macro is executed conditionally, but nothing is displayed.
Maybe you can suggest if such an implementation exists using DynamicMacros, or if a specific syntax is required?
Thank you in advance for your answer and the time spent
Beta Was this translation helpful? Give feedback.
All reactions