<commit_before>#!/usr/bin/env python3

'''
    Process two different streams
    in parallel
'''

import rx
import asyncio
from concurrent.futures import ProcessPoolExecutor

import APIReaderTwitter as Twitter

try:
    import json
except ImportError:
    import simplejson as json

def is_not_delete(element):
    return not "delete" in element

def is_delete(element):
    return "delete" in element

def pretty_print(element):
    print(json.dumps(element, indent=4))

def process_deleted():
    twitter_stream = rx.Observable.from_(Twitter.get_iterable())
    deleted_stream = twitter_stream.filter(is_not_delete)
    deleted_stream.subscribe(pretty_print)

def process_tweets():
    twitter_stream = rx.Observable.from_(Twitter.get_iterable())
    tweet_stream = twitter_stream.filter(is_delete)
    tweet_stream.subscribe(pretty_print)

if __name__ == "__main__":
    executor = ProcessPoolExecutor(2)
    loop = asyncio.get_event_loop()
    
    deleted = asyncio.async(loop.run_in_executor(executor, process_deleted))
    tweets  = asyncio.async(loop.run_in_executor(executor, process_tweets))
    
    loop.run_forever()<commit_msg>Just whitespace.<commit_after>#!/usr/bin/env python3

'''
    Process two different streams
    in parallel
'''

import rx
import asyncio
from concurrent.futures import ProcessPoolExecutor

import APIReaderTwitter as Twitter

try:
    import json
except ImportError:
    import simplejson as json

def is_not_delete(element):
    return not "delete" in element

def is_delete(element):
    return "delete" in element

def pretty_print(element):
    print(json.dumps(element, indent=4))

def process_deleted():
    twitter_stream = rx.Observable.from_(Twitter.get_iterable())
    deleted_stream = twitter_stream.filter(is_not_delete)
    deleted_stream.subscribe(pretty_print)

def process_tweets():
    twitter_stream = rx.Observable.from_(Twitter.get_iterable())
    tweet_stream = twitter_stream.filter(is_delete)
    tweet_stream.subscribe(pretty_print)

if __name__ == "__main__":
    executor = ProcessPoolExecutor(2)
    loop = asyncio.get_event_loop()

    deleted = asyncio.async(loop.run_in_executor(executor, process_deleted))
    tweets  = asyncio.async(loop.run_in_executor(executor, process_tweets))

    loop.run_forever()
{'fraction_non_alphanumeric': 0.09178743961352658, 'fraction_numerical': 0.002635046113306983, 'mean_word_length': 4.826086956521739, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4593908', 'n_tokens_mistral': 739, 'n_tokens_neox': 732, 'n_words': 148}