Esempio n. 1
0
class SchedulingService(Service):
    """
    Simple L{IService} implementation.
    """
    def __init__(self):
        self.coop = Cooperator(started=False)

    def addIterator(self, iterator):
        return self.coop.coiterate(iterator)

    def startService(self):
        self.coop.start()

    def stopService(self):
        self.coop.stop()
Esempio n. 2
0
class SchedulingService(Service):
    """
    Simple L{IService} implementation.
    """
    def __init__(self):
        self.coop = Cooperator(started=False)

    def addIterator(self, iterator):
        return self.coop.coiterate(iterator)

    def startService(self):
        self.coop.start()

    def stopService(self):
        self.coop.stop()
Esempio n. 3
0
def _pump_client(http_client):
    """
    Periodically flush all data in the HTTP client while this context manager
    is active.

    py:`treq.testing.RequestTraversalAgent` doesn't automatically pass data
    between a client and server, if a response isn't generated synchronously,
    so if we want requests to complete, we need to call ``.flush`` on it.

    :param treq.client.HTTPClient http_client:
        An HTTP Client wrapping a :py:`treq.testing.RequestTraversalAgent`.
    """
    def pump():
        while True:
            http_client._agent.flush()
            yield

    coop = Cooperator()
    task = coop.cooperate(pump())
    try:
        yield
    finally:
        task.stop()
        coop.stop()