Red Hat Bugzilla – Bug 972429
BodhiClient is not working properly if running in thread and from interative interpreter
Last modified: 2013-06-09 11:27:55 EDT
Created attachment 758721 [details]
Description of problem:
BodhiClient is not working when it's invoked from python interactive interpreter and running in Thread
Version-Release number of selected component (if applicable):
Steps to Reproduce:
Try to run attached file as:
$ python bodhiqthread.py
Then firstly run python interpreter and then import bodhiqthread
>>> import bodhiqthread
If running in interactive python interpreter, Bodhi never return results.
Some results from Bodhi.
I've tested this on F17 and F18 as well.
It is also reproducable if you create new python file and fill it with:
So the problem is not with interactive interpreter but when it's imported as library.
We ran through some debugging over IRC and think we figured this out. The python stdlib threading docs say this:
Firstly, other than in the main module, an import should not have the side effect of spawning a new thread and then waiting for that thread in any way. Failing to abide by this restriction can lead to a deadlock if the spawned thread directly or indirectly attempts to import a module.
What we think is happening in the example is that bodhiqthread() is spawning the thread as a side effect. Removing the call to Starter() from bodhiqthread() and instead calling bodhiqthread.Starter() from the python prompt works. It should be possible to restructure the program so that the new thread is only spawned from a function or method call, not as a side effect of importing.
Feel free to reopen if you find that this is not what's happening.