The import multiprocessing
Def download_data (q) :
# download data
Data=https://bbs.csdn.net/topics/[44] 11, 22, 33,
Print (' download... ')
For temp in data:
Q.p ut (temp)
Print (' the download is complete.. ')
Def analysis_data (q) :
# to get the data
Waitting=list ()
# data
While True:
Data=(https://bbs.csdn.net/topics/q.get)
Waitting. Append (data)
If q.e mpty () :
Break
Print (waitting)
Def the main () :
# to create a file
Q=multiprocessing Queue ()
P1=multiprocessing. Process (target=download_data, args=(q,))
P2=multiprocessing. Process (target=analysis_data, args=(q,))
P1. The start ()
P2. The start ()
If __name__=="__main__ ':
The main ()
This is the result of running under Ubuntu:
This is the result of running under Windows 10:
CodePudding user response:
Why missing picture?CodePudding user response:
Zha couldn't show the picture?Which means that the final want to output a list of,22,33,44 [11] same
Win it is a normal
But in Ubuntu, only [11]
CodePudding user response:
Friend,I also recently in the study, and I said my idea, not to, you when a train of thought for your reference, I don't think this code is rigorous, ubuntu and Windows running results are possible in my opinion, only the ubuntu without insert judged to be empty when I was 22, so the output termination loop, but may be because of the difference of running speed, Windows without this happening, I think you can add delay time of 0.1 s on while True, make sure to add and remove, but it is not good, another method, if where to==44 can also, this method, it goes to the last value so far out of circulation,