Python global threading.condition() and use in multiple modules
Question: **EDIT: the problem I was experiencing was not related to the structure of my
program. It was FAPWS3's routing picking a similar, closely named function.**

I have a large program spread across multiple files. I need to use the
threading.condition() locking functionality across these files. Here's an
example of what I'm trying to do. In production I do not get any errors, but
the state of the lock does not seem to be shared (I can acquire in one thread,
and acquire in another thread without the previous being released).

main.py

    
    
    import servera, serverb
    
    # some code that deploys server-a and server-b as threads
    

constants.py

    
    
    import threading
    mylock = threading.Condition()
    

servera.py

    
    
    from constants import mylock
    
    Class ServerA():
      def doSomething():
        mylock.acquire()
        # do something
        mylock.release()
    

serverb.py

    
    
    from constants import mylock
    
    Class ServerB():
      def doSomethingElse():
        mylock.acquire()
        # do something else
        mylock.release()
    


Answer: If I remember correct, when you import an module Python runs it. So I think
you get a different mylock in each file. You could try printing it and look at
the ids.

Jeffs link posted below clears that:

> Because there is only one instance of each module, any changes made to the
> module object get reflected everywhere.

So this is not a problem.

