471,350 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Need help with strange segfault

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 mi***@qlogic.com
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
Sep 5 '07 #1
0 810

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Robert Frunzke | last post: by
6 posts views Thread by Code Raptor | last post: by
9 posts views Thread by Eric Lilja | last post: by
30 posts views Thread by James Daughtry | last post: by
14 posts views Thread by ptq2238 | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.