Home > other >  Python thread pool to use while True and for I in range (number of infinite) submit thread way what&
Python thread pool to use while True and for I in range (number of infinite) submit thread way what&

Time:11-22

[align=left]
With ThreadPoolExecutor (max_workers=10) as executor:
Print (" to start the cycle ")
For temp range in (number) :
Task=executor. Submit (serial_test fina_text_content)
Task. Add_done_callback (get_result)
Print (" done ")
Executor. Shutdown ()
[/align]
When using the for I in range () submit to submit the form of threads, memory will be in a certain range, the value not too high,

[align=left]

With ThreadPoolExecutor (max_workers=10) as executor:
Print (" to start the cycle ")
While True:
Task=executor. Submit (serial_test fina_text_content)
Task. Add_done_callback (get_result)
Print (" done ")
Executor. Shutdown ()
[/align]
When using the while True submit to submit the form of threads, memory will continue to rise, finally will eat the memory is full,

Don't know much about this principle, if the number is infinite, but it is not like the while true effect is the same?


CodePudding user response:

While needs a exit criteria
  • Related