Search code examples
pythonparallel-python

When using Parallel Python, is there any way to tell on which machine the job has run?


I have written a simple program using parallel python, and all works well. However, mainly for curiosities sake, I would like to know on which machine each task ran, and how long it took.

Is there any way to programmatically get this information for the job that is returned?


Solution

  • A uuid1 could help:

    >>> import uuid
    >>> uuid.uuid1()
    UUID('b46fa8cf-1fc1-11df-b891-001641ec3fab')
    >>>
    

    See pydoc uuid and the RFC 4122 for more details, I think the last 48 bits are unique to the host. Not sure you you call/return that in Parallel python though.

    In the pp.py I found:

    self.__stats[hostid] = _Statistics(ncpus, rworker)
    

    Can you then use get_stats() to get at that:

    get_stats(self) Returns job execution statistics as a dictionary.