[Python] Static Analysis with Python BaseManager, how can I avoid it?

Discussão em 'Python' iniciado por Stack, Maio 31, 2025.

  1. Stack

    Stack Membro Participativo

    I have a problem when i register a class at runtime on my BaseManager. It's pretty obvious that static analysis cannot tell what that function is, but how can I avoid it?

    import multiprocessing.managers


    class InternalStatus:
    def __init__(self):
    self.value = 42

    def get_value(self):
    return self.value


    class InternalStatusManager(multiprocessing.managers.BaseManager):
    pass


    InternalStatusManager.register("InternalStatus", InternalStatus)

    if __name__ == "__main__":
    manager = InternalStatusManager()
    manager.start()
    ist = manager.InternalStatus() # here I get an error, since this function is not recognized
    print(ist.get_value())


    I don't know what to do, is there any other method to obtain the same result and get a shared istance of my class?

    Continue reading...

Compartilhe esta Página