The conditional test only needs function arguments, but the code it executes touch a global that needs protection.

I could put a lock inside every conditional body that needs it.  I decided for brevity to just do it once -- mostly, those getattribute calls are rarely used, there's no performance issue.  The threads check doesn't need the check because it's an atomic already.