Skip to content

Monitor GPU poll is bad #329

@Delaunay

Description

@Delaunay

class Monitor(Thread):
    """Thread that calls a monitoring function every ``delay`` seconds."""

    def __init__(self, delay, func):
        super().__init__(daemon=True)
        self.stopped = False
        self.delay = delay
        self.func = func
        self.start_time = time.time()
        self.count = 0

    def run(self):
        while not self.stopped:
            time.sleep(0)
            self.func()
            self.count += 1

    def stop(self):
        self.stopped = True
        # (time.time() - self.start_time) / self.count = 2sec  when self.delay == 0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions