Need help with strange segfault

  • Thread starter Mitko Haralanov
  • Start date
M

Mitko Haralanov

I am attempting to get a working wrapper around the TransactionSet
class from the rpm module but I am getting unexplained segfaults
in /usr/bin/python.

The reason why I am working on a wrapper is that I want to have a
single RPM abstraction module which is thread-safe and does not tie up
the RPM database. So here is my wrapper class:

class Transaction:
def __init__ (self, db=None):
self.ts = None
self.ts_lock = Lock ()
self.db = db
self.func = None

# This method will acquire the lock, record the TransactionSet
# method being called by the caller and return the pointer to
# the call_ts_func () function, which will do all the work.
def __getattr__ (self, name):
self.ts_lock.acquire ()
self.func = name
return self.call_ts_func

# This method serves as a wrapper around the actual TransactionSet
# method being called. It will open the database, call the
# TransactionSet method, close the databse, and then release the
# lock acquired in the __getattr__ () function.
def call_ts_func (self, *args):
if not self.ts:
if self.db: rpm.addMacro ("_dbpath", self.db)
self.ts = rpm.TransactionSet ()
self.ts.openDB ()
if self.db: rpm.delMacro ("_dbpath")

func = self.ts.__getattribute__ (self.func)
rs = func (*args)

self.func = None
self.ts.clean ()
self.ts.closeDB ()
del self.ts
self.ts = None
self.ts_lock.release ()
return rs

I am getting what appears to be a correct value in rs but as soon as I
try to access it from the caller function, Python segfaults.

Any help would be appreciated?

--
Mitko Haralanov (e-mail address removed)
Senior Software Engineer 650.934.8064
System Interconnect Group http://www.qlogic.com

==========================================
Any programming language is at its best before it is implemented and
used.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top