0

Does Dramatiq offer a way to get some sort of a human-readable name of the worker within the @dramatiq.actor function? I would use this to separate log lines from different works.

For example, something like dramatiq-process-1-worker-3.

@dramatiq.actor(broker=redis_broker, store_results=True, result_ttl=10*1000)
def ping():
     # Log worker name here
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435

1 Answers1

1
  • you can use the CurrentMessage middllware
from dramatiq.middleware import CurrentMessage

@dramatiq.actor(broker=redis_broker, store_results=True, result_ttl=10*1000)
def ping():
    msg = CurrentMessage.get_current_message()
    print(msg.actor_name)

Tal Leibman
  • 306
  • 4
  • 4