Python not wait for sub Function
-
Hello Guys,
I have a problem with my function...
i hope anyone can help my out.this is my sample code:
def generatePDF(self, data, customer, customer_project, materiallistType): Querry = [] Querry.append(['Herstellerbeschreibung', 'Herstellernummer', 'Lieferantennummer', 'Anzahl', 'Preis', 'Kommentar']) Querry.extend(data) filePath = self.setFileNamePDF(customer, customer_project, materiallistType) # while filePath is None: # pass print("Bin hier FEHLER ???") print(filePath) sys.exit(1)
my Problem here is that
print(filePath)
is None....
but i did not understand why...when i try something like that in an Test.py it works but not here.... does anyone know why ?
-
@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
-
@cvp said:
@DavinE Sincerely, I don't know but personally I would put the @on_main_thread before the other def.
it works xD Thanks @cvp
-
@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.
-
last edited by
-
@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()