Bug 972429 - BodhiClient is not working properly if running in thread and from interative interpreter
BodhiClient is not working properly if running in thread and from interative ...
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: python-fedora (Show other bugs)
18
x86_64 Linux
unspecified Severity medium
: ---
: ---
Assigned To: Toshio Ernie Kuratomi
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-09 06:42 EDT by Branislav Blaškovič
Modified: 2013-06-09 11:27 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-06-09 11:27:55 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Bodhi reproducer (556 bytes, text/x-python)
2013-06-09 06:42 EDT, Branislav Blaškovič
no flags Details

  None (edit)
Description Branislav Blaškovič 2013-06-09 06:42:27 EDT
Created attachment 758721 [details]
Bodhi reproducer

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):
  python-fedora-0.3.32.3-1.fc18.noarch
  python-fedora-0.3.32.3-1.fc17.noarch

How reproducible:
  always

Steps to Reproduce:

  Try to run attached file as:
    $ python bodhiqthread.py

  Then firstly run python interpreter and then import bodhiqthread
    $ python
    >>> import bodhiqthread

Actual results:
  If running in interactive python interpreter, Bodhi never return results.

Expected results:
  Some results from Bodhi.

Additional info:
  I've tested this on F17 and F18 as well.
Comment 1 Branislav Blaškovič 2013-06-09 07:28:53 EDT
It is also reproducable if you create new python file and fill it with:

  import bodhiqthread

So the problem is not with interactive interpreter but when it's imported as library.
Comment 2 Toshio Ernie Kuratomi 2013-06-09 11:27:55 EDT
We ran through some debugging over IRC and think we figured this out.  The python stdlib threading docs say this:

http://docs.python.org/2.7/library/threading.html#importing-in-threaded-code

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.

Note You need to log in before you can comment on or make changes to this bug.