<s> from rx . subjects import Subject <EOL> from threading import Thread <EOL> def _perform_subscribe ( stream , observer ) : <EOL> stream . subscribe ( observer ) <EOL> def build_threads ( stream_to_testers , thread_target = _perform_subscribe ) : <EOL> threads = [ ] <EOL> for stream , testers in stream_to_testers . items ( ) : <EOL> subject = Subject ( ) <EOL> for tester in testers : <EOL> subject . subscribe ( tester ) <EOL> threads . append ( _make_thread ( thread_target , stream , subject ) ) <EOL> return threads <EOL> def _make_thread ( thread_target , stream , subject ) : <EOL> return Thread ( target = thread_target , args = ( stream , subject ) ) <EOL> def launch_threads ( threads ) : <EOL> for thread in threads : <EOL> thread . start ( ) </s>
