How do I get a list of / number of running workers from the Python SDK?

I’ve tried finding this in the docs but I might have missed it. I want to create a simple function that shows the number of running workers (just like in the temporal UI) but I could not find the right method. Did I miss it?

From cli / tctl you can get it by describing the task queue, for example:

tctl tq desc --tq $taskQueueName

temporal task-queue describe -t $taskQueueName

The api for this is

Note it shows worker identities that have polled on specific task queue in the last 2 minutes, so might not be always completely accurate (for example if one of your workers just went down).