Bug 711525 - Connection.establish locks up when using subprocess
Summary: Connection.establish locks up when using subprocess
Keywords:
Status: NEW
Alias: None
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: python-qpid
Version: 1.3
Hardware: i686
OS: Linux
medium
high
Target Milestone: ---
: ---
Assignee: messaging-bugs
QA Contact: MRG Quality Engineering
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-06-07 18:03 UTC by Nick Capito
Modified: 2020-11-04 18:28 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:


Attachments (Terms of Use)
Test script to stimulate the issue (1.54 KB, text/x-python)
2011-06-07 18:03 UTC, Nick Capito
no flags Details

Description Nick Capito 2011-06-07 18:03:56 UTC
Created attachment 503546 [details]
Test script to stimulate the issue

If we call the Connection.establish("any broker"), and then spawn a process that has a Connection.establish("any broker") the Connection.establish will never return.


I have provided a test script to illustrate the problem.  Its a simple script it basically does the following:


1.  Create a connection and receiver
2.  Spawn the Process class
3.  The process class spawns 2 threads which call Connection.establish

You will see the Connection.establish never returns.


---

Notes from messing around with this I think the issue is relating to the drives _buf attribute getting cleared/currupted.  I can see headers getting packed, and then randomly getting cleared by some extenernal process.

Comment 1 Nick Capito 2011-06-07 18:45:20 UTC
The issue might be with the Selector class, it basically is reusing the same selector, but when we create the child process this is no longer valid.


Potential fix:

class Selector:

  lock = Lock()
  DEFAULT = {}

  @staticmethod
  def default():
    Selector.lock.acquire()
    try:
      process_id = os.getpid()
      if(not Selector.DEFAULT.has_key(group)):
        sel = Selector()
        atexit.register(sel.stop)
        sel.start()
        Selector.DEFAULT[process_id] = sel
      return Selector.DEFAULT[process_id]
    finally:
      Selector.lock.release()

Comment 2 Nick Capito 2011-06-07 18:51:04 UTC
There is a typo in the abox the


  if(not Selector.DEFAULT.has_key(group)):

should read 

  if(not Selector.DEFAULT.has_key(process_id)):


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