Bug 972429 - BodhiClient is not working properly if running in thread and from interative interpreter
Summary: BodhiClient is not working properly if running in thread and from interative ...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: python-fedora
Version: 18
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Toshio Ernie Kuratomi
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-06-09 10:42 UTC by Branislav Blaškovič
Modified: 2013-06-09 15:27 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-06-09 15:27:55 UTC
Type: Bug
Embargoed:


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

Description Branislav Blaškovič 2013-06-09 10:42:27 UTC
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 11:28:53 UTC
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 15:27:55 UTC
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.