Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python oword freezes UI #2967

Open
TurBoss opened this issue Apr 21, 2024 · 10 comments
Open

Python oword freezes UI #2967

TurBoss opened this issue Apr 21, 2024 · 10 comments

Comments

@TurBoss
Copy link
Contributor

TurBoss commented Apr 21, 2024

Hello

python OWORD freezes UI

Here are the steps I follow to reproduce the issue:

This was tested on axis

  1. write a python oword.py file with this content
import time


def test_sleep(self, n):
    print("Timer started")
    time.sleep(n)  # wait n seconds
    print("Timer ended")
  1. from a G-CODE file or MDI input run o<test_sleep> call [10]

This is what I expected to happen:

The UI to begin responsive while OWORD is waiting

This is what happened instead:

The UI gets stuck until sleep ends and is not possible to interact with any element


I`m not sure if this is an issue or its normal

Thanks

@jethornton
Copy link
Collaborator

jethornton commented Apr 22, 2024

Python time.sleep() is a blocking call and all processing stops until it times out.

time.sleep(secs)

   Suspend execution of the calling thread for the given number of seconds.
   The argument may be a floating point number to indicate a more precise sleep time.

   If the sleep is interrupted by a signal and no exception is raised by the signal handler,
    the sleep is restarted with a recomputed timeout.

   The suspension time may be longer than requested by an arbitrary amount,
   because of the scheduling of other activity in the system.

@c-morley
Copy link
Collaborator

But this python context is gcode(motion controller), the GUI should no be affected.as it's a different python Interpreter.
Something sounds not right.
Is there any other info you can give?

@c-morley
Copy link
Collaborator

what GUI are you using?

@jethornton
Copy link
Collaborator

Thanks Chris, I didn't know that the gcode was executed with a different python instance.

@c-morley
Copy link
Collaborator

Well I may he miss understanding. I don't see in thr docs where an oword sub can be made in python.

@jethornton
Copy link
Collaborator

And I just looked as well and could not find anything about an oword sub in python. AFAIK only M100-199 can be in a programming language.

@jethornton
Copy link
Collaborator

Running Axis sim and creating the file and running the oword command I get:
EOF in file:usr/share/axis/images/axis.ngc
seeking o-word: o<test_sleep> from line: 0

@andypugh
Copy link
Collaborator

Well, you probably can run Python as an O-word sub, but it's not well documented.

This works as a subroutine....

O<pytest> SUB
;py,import sys
;py,print(sys.version)
O<pytest> ENDSUB
M2

@TurBoss
Copy link
Contributor Author

TurBoss commented Apr 23, 2024

hello,

thanks for your responses

calling python from gcode sub also has the same issue

o<pytest> sub

;py,import time
;py,time.sleep(10)

o<pytest> endsub

o<pytest> call

while this works



o<sleep> sub

G1 x1 F10
G4 P10
G1 x2 F10

o<sleep> endsub

o<sleep> call

@rmu75
Copy link
Contributor

rmu75 commented Apr 26, 2024

this seems to be a very obscure and unsafe feature.

o<pytest> sub

;py,while True: pass

o<pytest> endsub

o<pytest> call

I suspect the GUIs block at status update (ngc-interpreter is occupied in python and doesn't answer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants