<s> import uuid <EOL> import diesel <EOL> import diesel . runtime <EOL> def waiting_green_thread ( wait_id , done ) : <EOL> diesel . wait ( wait_id ) <EOL> done . append ( True ) <EOL> def test_wait_tokens_dont_accumulate_forever ( ) : <EOL> """<STR_LIT>""" <EOL> done = [ ] <EOL> wait_ids = [ ] <EOL> expected_length = len ( diesel . runtime . current_app . waits . waits ) <EOL> for i in xrange ( <NUM_LIT:50> ) : <EOL> wait_id = uuid . uuid4 ( ) . hex <EOL> diesel . fork ( waiting_green_thread , wait_id , done ) <EOL> diesel . sleep ( ) <EOL> wait_ids . append ( wait_id ) <EOL> for wait_id in wait_ids : <EOL> diesel . fire ( wait_id ) <EOL> diesel . sleep ( ) <EOL> while len ( done ) != <NUM_LIT:50> : <EOL> diesel . sleep ( <NUM_LIT:0.1> ) <EOL> actual_length = len ( diesel . runtime . current_app . waits . waits ) <EOL> assert actual_length == expected_length , actual_length </s>
