[Python-Dev] adding threaded tests to the test suite

Martin Panter vadmium+py at gmail.com
Sun Jan 22 15:39:16 EST 2017


> Le dim. 22 janv. 2017 à 21:04, Ethan Furman <ethan at stoneleaf.us> a écrit :
>> Question:  I need to add a threaded test to the enum test module [1] -- is
>> there anything extra I
>> need to worry about besides the test itself?  Setting or resetting or
>> using a tool library, etc?
>>
>> threads = []
>> for i in range(8):
>>     threads.append(threading.Thread(target=cycle_enum))
>> for t in threads:
>>     t.start()
>> for t in threads:
>>     t.join()

On 22 January 2017 at 20:17, Victor Stinner <victor.stinner at gmail.com> wrote:
> There is @support.reap_thread which can help.

As I understand, @reap_threads basically does a join() on each
background thread, with a total timeout of 1 s. So since your test is
unlikely to fail between starting threads and joining them, I don’t
think you need to use @reap_threads.


More information about the Python-Dev mailing list