Zac Burns wrote: > Using python 2.6 > > cPickle.dumps has an import which is causing my application to hang. > (figured out by overriding builtin.__import__ with a print and seeing > that this is the last line of code being run. I'm running > cPickle.dumps in a thread, which leads me to believe that the first > restriction here is the cause: > http://docs.python.org/library/threading.html#importing-in-threaded-code > > What can I do about this?
You can do two things to stop the import lock from dead locking. * Never ever start a thread as a side effect of an import. This means you must not start a thread in the body of a module. As I explained in numerous other messages a well designed application imports all its modules first. After all modules have been imported the components are initialized and the threads are started. * Import all modules that are referred inside your pickled data before you unpickle. Christian -- http://mail.python.org/mailman/listinfo/python-list