Ok got it.
The problem come from the Global Interpreter Lock from Python. run()
seems to run the code in an other thread as step() run the code in the
same thread as python. So, when calling the function via step(), the
lock is already acquired by the thread. On the other hand, run() is into
a different thread, and the lock has to be acquired manually.
Using boost, I was expecting an exception instead of crash for this kind
of error.
Functions should look like:
virtual Real contactForce(Real const& u) const {
TRACE;
gilLock lock; // Acquire GIL. (from pyutils/gil.hpp)
LOG_TRACE("GIL State: " << PyGILState_Check());
return get_override("contactForce")(u);
}
I'll update the doc about subclassing c++ in python, as this is
mandatory for all python code called from C++ while running O.run().
William.
On 08/10/2019 13:22, William Chèvremont wrote:
Hi,
Yes, there are the same behaviour with and without wait.
William
On 08/10/2019 12:57, Bruno Chareyre wrote:
Hi William,
I don't know precisely but in case it can help I would raise that the
main difference between step() and run() is Py_BEGIN_ALLOW_THREADS,
at least if O.run(...,wait=True).
Do you have the same problem with and without "wait"?
Simply passing to c++ a python expression (just a string with python
commands) or a python function returning a value - instead of a
derived class object - could be a simple workaround maybe.
Bruno
On Tue, 8 Oct 2019 at 10:56, William Chèvremont
<william.chevrem...@univ-grenoble-alpes.fr
<mailto:william.chevrem...@univ-grenoble-alpes.fr>> wrote:
Hi,
@Janek
Yes, I'm aware of the doc about subclassing types in python.
There are
no problem about that, since it works when calling O.step()
instead of
O.run().
@Anton
The complete backtrace is attached to this mail. Functions of
interests
are around line 400.
Best Regards,
William
On 07/10/2019 18:19, Janek Kozicki (yade) wrote:
> Only a quick question to make sure - you have read
https://yade-dem.org/doc/prog.html#subclassing-c-types-in-python
in documentation?
>
>
> best regards
> Janek
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-dev
> Post to : yade-dev@lists.launchpad.net
<mailto:yade-dev@lists.launchpad.net>
> Unsubscribe : https://launchpad.net/~yade-dev
> More help : https://help.launchpad.net/ListHelp
_______________________________________________
Mailing list: https://launchpad.net/~yade-dev
Post to : yade-dev@lists.launchpad.net
<mailto:yade-dev@lists.launchpad.net>
Unsubscribe : https://launchpad.net/~yade-dev
More help : https://help.launchpad.net/ListHelp
--
--
_______________
Bruno Chareyre
Associate Professor
ENSE³ - Grenoble INP
Lab. 3SR
BP 53
38041 Grenoble cedex 9
Tél : +33 4 56 52 86 21
________________
Email too brief?
Here's why: email charter
<https://marcuselliott.co.uk/wp-content/uploads/2017/04/emailCharter.jpg>
_______________________________________________
Mailing list: https://launchpad.net/~yade-dev
Post to : yade-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-dev
More help : https://help.launchpad.net/ListHelp
_______________________________________________
Mailing list: https://launchpad.net/~yade-dev
Post to : yade-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-dev
More help : https://help.launchpad.net/ListHelp