Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swf/worker: log activity spawn and completion details #413

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions simpleflow/swf/process/worker/base.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from __future__ import annotations

import json
import logging
import os
import sys
import traceback
import uuid
from base64 import b64decode

import multiprocess
import multiprocess.util
import psutil

import swf.actors
Expand Down Expand Up @@ -237,10 +239,18 @@ def process(self, poller, token, task, middlewares=None):
return poller.fail_with_retry(token, task, reason=reason, details=details)

try:
logger.info("completing activity")
logger.info(
"completing activity id=%s worker pid=%d",
task.activity_id,
os.getpid(),
)
poller.complete_with_retry(token, result)
except Exception as err:
logger.exception("complete error")
logger.exception(
"failed to complete activity id=%s worker pid=%d",
task.activity_id,
os.getpid(),
)
reason = "cannot complete task {}: {} {}".format(
task.activity_id,
err.__class__.__name__,
Expand Down Expand Up @@ -331,7 +341,13 @@ def spawn(poller, token, task, middlewares=None, heartbeat=60):
:param heartbeat: heartbeat delay (seconds)
:type heartbeat: int
"""
logger.info("spawning new activity worker pid={} heartbeat={}".format(os.getpid(), heartbeat))
logger.info(
"spawning new activity id=%s worker pid=%d heartbeat=%s",
task.activity_id,
os.getpid(),
heartbeat,
)
multiprocess.util.log_to_stderr(logging.INFO)
worker = multiprocess.Process(target=process_task, args=(poller, token, task, middlewares))
worker.start()

Expand Down