How to use the eliot.Action.continue_task function in eliot

To help you get started, we’ve selected a few eliot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-voca / voca / src / voca / worker.py View on Github external
async def async_main(wrapper_group: utils.WrapperGroup):
    """Process input commands as newline-separated json on stdin."""
    stream = trio._unix_pipes.PipeReceiveStream(os.dup(0))
    receiver = streaming.TerminatedFrameReceiver(stream, b"\n")

    async for message_bytes in receiver:
        data = json.loads(message_bytes.decode())

        try:
            with eliot.Action.continue_task(
                task_id=data.get("eliot_task_id", "@")
            ) as action:
                await handle_message(wrapper_group=wrapper_group, data=data)
        except Exception as e:
            action.finish(e)
            raise

        sys.exit(0)
github ClusterHQ / flocker / flocker / control / _protocol.py View on Github external
def fromStringProto(self, inString, proto):
        return Action.continue_task(
            proto.logger,
            Unicode.fromStringProto(self, inString, proto))
github itamarst / eliot / examples / cross_process_server.py View on Github external
def main():
    with Action.continue_task(logger, request.headers["x-eliot-task-id"]):
        x = int(request.args["x"])
        y = int(request.args["y"])
        return str(divide(x, y))
github itamarst / eliot / eliot / dask.py View on Github external
def __call__(self, *args, **kwargs):
        with Action.continue_task(task_id=self.task_id) as action:
            action.log(
                message_type="dask:task", key=self.key, dependencies=self.dependencies
            )
            return self.func(*args, **kwargs)
github ClusterHQ / flocker / flocker / control / _protocol.py View on Github external
def fromStringProto(self, inString, proto):
        return Action.continue_task(
            proto.logger,
            Unicode.fromStringProto(self, inString, proto))
github ClusterHQ / flocker / flocker / restapi / _infrastructure.py View on Github external
def logger(self, request, **routeArguments):
        serialized_remote_task = request.requestHeaders.getRawHeaders(
            "X-Eliot-Task-Id", [None])[0]
        if serialized_remote_task is None:
            return original(self, request, **routeArguments)

        try:
            action = Action.continue_task(task_id=serialized_remote_task)
        except ValueError:
            return original(self, request, **routeArguments)
        with action.context():
            d = DeferredContext(original(self, request, **routeArguments))
            d.addActionFinish()
            return d.result
    return logger