You Are Here:

Community: Developer Discussion Boards

#1 Old Pythread error - 2005-02-01, 23:56

Join Date: Jan 2005
Posts: 20
pollyp
Offline
Registered User
Hi,

I'm writing an app that pulls streaming data off a rfcomm connection and writes it to stdout. I'm a Symbian n00b and have read the docs on threading and active object considerations. My app patterns itself after the application skeleton code: I have a main class that manages the Ao_lock and the ui, and a separate threaded class that reads from the socket and uses a callback to send the data. The UI class sits in a loop, waiting to grab the lock before writing the data, and its callback signals() the lock.

So here's my problem: the socket recv call generates a "App closed PyThread!" message. If I comment out the recv and just send test data back, everything works fine.

I'm puzzled about what's going on here. Why would PyThread close my app based on a socket.recv call? Any hints about what I should try next?

Thanks,

Polly
Reply With Quote

#2 Old Re: Pythread error - 2005-02-02, 10:34

Join Date: Dec 2004
Posts: 646
jplauril's Avatar
jplauril
Offline
Forum Nokia Expert
Quote:
Originally posted by pollyp
Hi,

I'm writing an app that pulls streaming data off a rfcomm connection and writes it to stdout. I'm a Symbian n00b and have read the docs on threading and active object considerations. My app patterns itself after the application skeleton code: I have a main class that manages the Ao_lock and the ui, and a separate threaded class that reads from the socket and uses a callback to send the data. The UI class sits in a loop, waiting to grab the lock before writing the data, and its callback signals() the lock.

So here's my problem: the socket recv call generates a "App closed PyThread!" message. If I comment out the recv and just send test data back, everything works fine.

I'm puzzled about what's going on here. Why would PyThread close my app based on a socket.recv call? Any hints about what I should try next?

Thanks,

Polly
Could you post your code here? The first idea that comes to my mind is that you may be inadvertently trying to use a native object from a different thread than it was created in.
Reply With Quote

#3 Old Pythread error - solved - 2005-02-09, 21:38

Join Date: Jan 2005
Posts: 20
pollyp
Offline
Registered User
Your first guess was very good indeed. :^)

I was creating the socket in the class's init method, then starting the new thread with a method that did the actual receive. Moving the socket creation into the same thread solved my problem. Even though other instance objects seem to behave well across thread creation, it appears that's not true of socket objects.

Thanks!

Polly
Reply With Quote

#4 Old 2005-02-10, 12:41

Join Date: Dec 2004
Posts: 646
jplauril's Avatar
jplauril
Offline
Forum Nokia Expert
Quote:
Originally posted by pollyp
Your first guess was very good indeed. :^)

I was creating the socket in the class's init method, then starting the new thread with a method that did the actual receive. Moving the socket creation into the same thread solved my problem. Even though other instance objects seem to behave well across thread creation, it appears that's not true of socket objects.
As a general rule, none of the Python objects that wrap a native Symbian resource are safe to use from a different thread that where they were created in. This applies at least to socket, e32db (and indirectly to e32dbm and anydbm) and appuifw.
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

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 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ