Thanks for your replies!
On Wed, 20 Mar 2013 16:34:00 -0000, Jim Bosch <tallji...@gmail.com> wrote:
I don't think shared_ptr would help here (and you almost certainly don't
want to inherit from it), though I'm curious what you're using to wrap
std::list, as you clearly have methods that return std::list, and the
standard library can be tricky to translate to Python due to things like
iterator invalidation.
Heh, not yet anyway! Although I've laid out the foundations, I haven't yet
implemented my attempt at a solution, nor tested it, as am still trying to
get rid of these seg-faults here.. I did however write a template class
for std::list, derived from indexing_suite. It was inspired by a
question[1] on StackOverflow, but edited to fulfill the obligations of a
class derived from indexing_suite (in
boost/python/suite/indexing/indexing_suite.hpp).
I've put it in a "boost_helpers" folder in my own project, but I'd be
perfectly happy if someone wanted to put it in mainline boost. I attach it
here, if you're interested in having it ;)
That said, containers of strings are much less tricky than containers
of wrapped objects. And given that your Python example that segfaults
doesn't involve those methods at all, they probably aren't at fault.
That's what I'm thinking.. I'm not calling a method or a factory function,
just an object's constructor and then its destructor. The base class's
destructor is a no-op, as is the one in my derived class. I've used that
MakeThreadSafe object in every wrapped function where the base class'
method locks the global mutex (source attached to first email in thread).
But I was getting these seg-faults, before I even started playing with the
GIL, as when compiled in release mode, the pthreads assertions don't raise
an error and execution continued to this seg-fault.
To me, everything thing here looks pretty straightforward, except the
multithreading...which leads me to suspect that the multithreading is
the problem. And that's something I'm afraid I don't know enough to
help you with.
Jim
--
Using Opera's mail client: http://www.opera.com/mail/
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig