<commit_before>#!/usr/bin/python -i

import os

import pytest

from circuits.core.manager import HAS_MULTIPROCESSING
if not HAS_MULTIPROCESSING:
    pytest.skip("Skip: No multiprocessing support")

from circuits.net.sockets import Pipe
from circuits import Event, Component, Bridge

class Hello(Event):
    """Hello Event"""

class App(Component):

    def hello(self):
        return "Hello from %d" % os.getpid()

def test():
    # Our communication transport
    a, b = Pipe()

    # 1st App (process)
    p = App()
    Bridge(p, socket=a)
    p.start(process=True)

    # 2nd App
    app = App()
    Bridge(app, socket=b)
    app.start()

    pid = os.getpid()
    e = Hello()
    assert e.future == False
    x = app.push(e)

    pytest.wait_for(e, "future", True)
    assert e.future == True

    def test(obj, attr):
        return isinstance(obj._value, list)

    pytest.wait_for(x, None, test)

    assert x[0] == "Hello from %s" % pid
    assert x[1].startswith("Hello from")
    assert not x[0]  == x[1]<commit_msg>tests.core.test_bridge: Stop runnign task after test<commit_after>#!/usr/bin/python -i

import os

import pytest

from circuits.core.manager import HAS_MULTIPROCESSING
if not HAS_MULTIPROCESSING:
    pytest.skip("Skip: No multiprocessing support")

from circuits.net.sockets import Pipe
from circuits import Event, Component, Bridge

class Hello(Event):
    """Hello Event"""

class App(Component):

    def hello(self):
        return "Hello from %d" % os.getpid()

def test():
    # Our communication transport
    a, b = Pipe()

    # 1st App (process)
    p = App()
    Bridge(p, socket=a)
    p.start(process=True)

    # 2nd App
    app = App()
    Bridge(app, socket=b)
    app.start()

    pid = os.getpid()
    e = Hello()
    assert e.future == False
    x = app.push(e)

    pytest.wait_for(e, "future", True)
    assert e.future == True

    def test(obj, attr):
        return isinstance(obj._value, list)

    pytest.wait_for(x, None, test)

    assert x[0] == "Hello from %s" % pid
    assert x[1].startswith("Hello from")
    assert not x[0]  == x[1]

    p.stop()
{'fraction_non_alphanumeric': 0.13099193165638348, 'fraction_numerical': 0.005695301376364499, 'mean_word_length': 2.910946196660482, 'pattern_counts': {'":': 0, '<': 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': '5687229', 'n_tokens_mistral': 761, 'n_tokens_neox': 733, 'n_words': 205}