Way to asynchronously run OS.execute()? #8871
time-killer-games
started this conversation in
General Discussions
Replies: 2 comments 4 replies
-
Have you tried running it in a thread? See here This is for proposing features, for support questions and help please first turn to the other community channels 🙂 |
Beta Was this translation helpful? Give feedback.
1 reply
-
os.execute will block the current thread, so you can run it in a thread. It can read output, but it won't return until the process is finished (and will set output string only after finishing). |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like a way to read from standard output, and write to standard input, and do so with a child process I executed, all asynchronously. Can all of this be technically done already or should I create a pull request? I'm relatively new to Godot and don't know much about what it can or can't do without a bit of research, and it is simpler to just ask and get a simple "yes" or "no". I have written my own C++ library which does all of these things, so I am more than happy to create a pull request at some point if I absolutely need to.
According to this the OS.execute() function blocks the main thread and according to this multithreading is possible in Godot, so on the surface, while putting one and one together, it would seem what I am asking is already possible in Godot. Is this true, and if so, does this apply to Godot 4 only or should it work in Godot 3 as well?
Also afaik there is a way to read standard output of a child process, but I saw nothing in the docs about writing to standard input of a child process, and in which case it seems that much will need a pull request from me one way or another if I am not sadly mistaken. Is this correct as well?
This is intended to make chess games with chess engine AI's like stockfish chess, for example, and among others, all of which are used as a IPC command line interface. (In my specific use case, this is why I need these features, but other use cases also exist obviously).
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions