question

Hao Zhou avatar image
0 Likes"
Hao Zhou asked Hao Zhou commented

FlexSimPy Example Failed for 23.1

I am trying to use a newer engine 23.1.2. I also check out the FlexSimPy 23.1 revision and it can build without any problems. I am using Python 3.10 and setup the version accordingly in FlexSim and VS build config. However, when I run the example TestFlexSimPy.py, I got the following error.

In addition, the same example runs really well for engine 22.1. Could you please provide suggestions to fix the issue. Thanks so much for the help!

Starting
imported
launched
Fatal Python error: PyThreadState_GetReceived  15.0
: the function must be called with the GIL held, but the GIL is released (the current Python thread state is NULL)
Python runtime state: initialized

Thread 0x00003f70 (most recent call first):
  File "C:\Users\haozhou\Documents\FlexSim 2023 Update 1\modules\FlexSimPy\TestFlexSimPy\TestFlexSimPy.py", line 26 in <module>
FlexSim 23.1.2
flexsim python
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Kavika F avatar image
0 Likes"
Kavika F answered Hao Zhou commented

Hey @Hao Zhou, I was able to replicate the error you're getting. After debugging the solution, I found that it was an error being thrown from the ~PyXDecRefPtr() destructor. This class was added after version 22.2, which explains why this error doesn't occur in v22.1 but does in v23.1. If you go to the "PyXDecRefPtr.h" file and comment out line 13 which should contain

~PyXDecRefPtr() { Py_XDECREF(object); }

then the Test file will work. I don't know what implications this will have on other parts of your model or scripts - I only tested it for the TestFlexSimPy project.

I'll add this case to the dev list to look into why this is happening. Thank you for finding this for us!

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Hao Zhou avatar image Hao Zhou commented ·
Thanks so much Kavika. The problem is solved by following your suggestions. I really appreciate. I will test how much this impacts on my other scripts. But it works perfectly for me for now.
1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.