python-zk/kazoo — pull request #105 by heckj (2013-07-15 16:09:51+00:00)
Title: moving imports to top of module

In using Kazoo, I periodically (intermittently) was seeing extensive CPU time consumed by threads/processes with kazoo clients, and traced it back with strace to repeated futex locks while creating Kazoo client instances. Google research suggested that similiar system errors ending in deadlock was caused by imports outside of the module loading pathing (i.e. in methods, etc).

I made this change locally, tested it, and verified the occurance of the GIL locks decreased dramatically, so I'm hoping this will avoid future issues for someone else.