Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
def fromStringProto(self, inString, proto):
return Action.continue_task(
proto.logger,
Unicode.fromStringProto(self, inString, proto))
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))
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)
def fromStringProto(self, inString, proto):
return Action.continue_task(
proto.logger,
Unicode.fromStringProto(self, inString, proto))
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