I'am trying to speedup a Python program , I made remark that there is a thread always running that scans the inputs from an external resource, and when it gets something, it will call another function that will parse the input data and return an understandable information (the parsing function also uses other functions).
A simple model of the scanning()
function
def scanning(x):
alpha = GetSomething(x)
if alpha != 0:
print Parsing(alpha)
So my idea is to convert this thread into a process that will run in parallel with the main process, and when it gets something, it will send it using a Queue to the main process which should then call the parsing function.
My questions are: it is possible to keep the scanning()
function as it is and use it inside a process (even if it calls other functions)?
If not, what are the required modifications on the structure of the scanning()
function to be used conveniently with the multiprocessing
module?
What is the proper way to multiprocess a function that calls other functions in Python ?