[Pulp-list] Fwd: [katello-devel] Python import advice

Nick Coghlan ncoghlan at redhat.com
Fri Jul 29 00:08:42 UTC 2011


On 07/29/2011 01:24 AM, Lukas Zapletal wrote:
> On 07/28/2011 05:10 PM, Jeff Ortel wrote:
>> circular import issue.
>
> Yes, moved to the method and its gone :-)

Be careful with doing imports inside functions or methods in library 
code - it can cause deadlocks if an application spawns threads as a side 
effect of import that then call those operations (see the first bullet 
point in 
http://docs.python.org/library/threading#importing-in-threaded-code)

Moving components around to eliminate the circular dependency is a 
preferable solution (e.g. just looking at the traceback, moving the 
definition of KatelloError out of the cli subpackage to an approporiate 
location in the core subpackage and providing an alias in the old 
location may be a more robust long term solution than just delaying the 
import).

Regards,
Nick.

-- 
Nick Coghlan
Red Hat Engineering Operations, Brisbane




More information about the Pulp-list mailing list