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?
--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
Not run it in a thread.
Isn't requesting that pickle not be used in a thread a bit of a tall
order? Just thinking through the common use cases - database access,
server request threads, file IO... pickle is commonly used in threads.
Furthermore, the pickle documentation makes no mention of not being threadsafe.
Please report a bug at http://bugs.python.org
Better even if you can provide a small snippet of code which reproduces
the problem reliably.
Regards
Antoine.
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