classification
Title: Pickling deadlocks in thread with python -m
Type: behavior Stage:
Components: Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Werner Smidt
Priority: normal Keywords:

Created on 2017-11-09 10:14 by Werner Smidt, last changed 2017-11-09 10:14 by Werner Smidt.

Files
File name Uploaded Description Edit
testqueuepickle.py Werner Smidt, 2017-11-09 10:14 python script
Messages (1)
msg305953 - (view) Author: Werner Smidt (Werner Smidt) Date: 2017-11-09 10:14
Hi there

I recently stumbled on an interesting behaviour.  I won't call it an error, because I think it's a mistake I made.  

BACKGROUND: I want to spawn threads that handle pickled data.  This works really well. However, I would like to execute the python script in question as a module, i.e. python -m mymodule. This is merely for aesthetic purposes.

The attached script has two functions:
1. Pickle/unpickle an instance of a `namedtuple`
2. Pickle/unpickle a string

Each of these functions are run in the main thread and then in subsequent spawned threads. 

If I run the script attached with "python testqueuepickle.py", it works fine.  I get the data pickled/unpickled in the respective functions and nothing deadlocks and everything is printed to screen. If, however, I run it with the "-m" option (python -m testqueuepickle.py) , the program deadlocks at the pickling of the "namedtuple" instance. The pickling/unpickling of the string appears to be unaffected. 

Programming practices aside, what do you think could be the cause of this?
History
Date User Action Args
2017-11-09 10:14:19Werner Smidtcreate