I filed this back in April, 2019 (FB5345023). I've found that if I bring the target to the front with NSRunningApplication.activateWithOptions before calling AEDeterminePermissionToAutomateTarget, the hangs don't occur. So that's a workaround, though ugly, depending on your use-case.
Topic:
App & System Services
SubTopic:
Core OS
Tags: