Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Python not wait for sub Function
-
@DavinE is your @ui.in_background needed?
-
@cvp, Honestly ? xD
i have no idea why i set this....
what does @ui.in_background and @on_main_thread exactly
-
@DavinE There are two base threads in Pythonista and you can force to run a process in The main_thread or in tHe ui one.
Remove this line and it is still not ok, put the line @on_main_thread -
@cvp like this:
@on_main_thread def generatePDF(...)
and here:
def setFileNamePDF(self, customer, customer_project, materiallistType)
nothing ?
-
@DavinE Sincerely, I don't know but personally I would put the @on_main_thread before the other def.
-
@cvp okay thanks i try it and response to you xD
-
-
@DavinE eureka
-
Hi everyone,
Is it possible to launch a python command without waiting for a return ? and therefore start the next command without waiting the previous one to finish ?
I searched and asked also on StackOverflow but so far I didn't found what I was looking for...
something that look promising might be the
1
concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
as seen here -> https://stackoverflow.com/a/60832288/11943028But this example is focus on results that I don't need. any ideas ?
Thank you.
-
-
@montykit see the threading module, you could start one thread for each command
But what do you call a command?
-
@montykit try
import threading class MyThread(threading.Thread): def __init__(self,cmd): threading.Thread.__init__(self) self.run = cmd def cmd1(): s = 0 for i in range(1000): s += 1 print(s) def cmd2(): s = 0 for i in range(1000): s += i print(s) MyThread(cmd1).start() MyThread(cmd2).start()