You Are Here:

Community: Developer Discussion Boards

#1 Old C++ extension callbacks changed in 1.9.2? - 2009-03-10, 15:08

Join Date: Feb 2009
Posts: 10
mauso
Offline
Registered User
Hi,

Implementing C++ extension that makes callbacks to a function in a python module.

In pys60 1.4.5 with S60 3rd FP1 these thread-state functions around the callback seem to work with no problem:
Code:
PyEval_RestoreThread( PYTHON_TLS->thread_state );
...
PyEval_SaveThread();
But on 1.9.2 with S60 5th the code won't build with those lines. Commenting them out makes it build succesfully but the python runtime at emulator crashes when the callback in the extension code is reached.

Have the PyEval_RestoreThread and/or PyEval_SaveThread functions changed between 1.4.5. and 1.9.2 (or python 2.2 and 2.5 respectively)? Any workarounds?
Reply With Quote

#2 Old Re: C++ extension callbacks changed in 1.9.2? - 2009-03-10, 16:08

Join Date: Mar 2003
Posts: 44
haviital
Offline
Registered User
Try this:

Code:
Py_Initialize();
PyEval_InitThreads();
...
Py_Finalize();
Reply With Quote

#3 Old Re: C++ extension callbacks changed in 1.9.2? - 2009-03-10, 19:47

Join Date: Oct 2007
Posts: 114
ashwinurao
Offline
Regular Contributor
Quote:
Originally Posted by mauso View Post
Hi,

Implementing C++ extension that makes callbacks to a function in a python module.

In pys60 1.4.5 with S60 3rd FP1 these thread-state functions around the callback seem to work with no problem:
Code:
PyEval_RestoreThread( PYTHON_TLS->thread_state );
...
PyEval_SaveThread();
But on 1.9.2 with S60 5th the code won't build with those lines. Commenting them out makes it build succesfully but the python runtime at emulator crashes when the callback in the extension code is reached.

Have the PyEval_RestoreThread and/or PyEval_SaveThread functions changed between 1.4.5. and 1.9.2 (or python 2.2 and 2.5 respectively)? Any workarounds?
Yes. We don't need to maintain the thread state anymore explicitly. We leave all the dirty work to the interpreter. Do a direct replace as shown below :

PyEval_RestoreThread( PYTHON_TLS->thread_state ) --> PyGILState_STATE gstate = PyGILState_Ensure();

PyEval_SaveThread() --> PyGILState_Release(gstate);


import antigravity
Reply With Quote

#4 Old Re: C++ extension callbacks changed in 1.9.2? - 2009-03-11, 04:47

Join Date: Apr 2007
Posts: 131
mahesh.sayibabu's Avatar
mahesh.sayibabu
Offline
Regular Contributor
Quote:
Originally Posted by mauso View Post
Hi,

Implementing C++ extension that makes callbacks to a function in a python module.

In pys60 1.4.5 with S60 3rd FP1 these thread-state functions around the callback seem to work with no problem:
Code:
PyEval_RestoreThread( PYTHON_TLS->thread_state );
...
PyEval_SaveThread();
But on 1.9.2 with S60 5th the code won't build with those lines. Commenting them out makes it build succesfully but the python runtime at emulator crashes when the callback in the extension code is reached.

Have the PyEval_RestoreThread and/or PyEval_SaveThread functions changed between 1.4.5. and 1.9.2 (or python 2.2 and 2.5 respectively)? Any workarounds?
Refer to the file, PyS60_1_9_x_README.txt under the src directory. The section "6.2 Porting PyS601.4.x extensions to PyS601.9.x" explains the changes that needs to be done for porting modules to 1.9.x.

=======
Mahesh
PyS60 Team
Reply With Quote

#5 Old Re: C++ extension callbacks changed in 1.9.2? - 2009-03-11, 10:07

Join Date: Feb 2009
Posts: 10
mauso
Offline
Registered User
Thanks for good&quick answers, problems solved so far
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Recording in Amr Format losym Symbian Media (Graphics & Sounds) 12 2009-03-26 07:41
Python for S60 1.9.2 released tvijayan Python 26 2009-03-11 10:28
WAP extension for Dreamweaver RichardGalbraith General Browsing 2 2009-01-13 04:21
KERN-EXEC 3 Panic/OK for the same call PACALA_BA General Symbian C++ 7 2009-01-04 17:48
what 's mean of Extension_() in CSession Class yinquan General Symbian C++ 7 2008-08-12 17:52

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia