Discussion Board

Results 1 to 4 of 4

Thread: Pythread error

  1. #1
    Registered User pollyp's Avatar
    Join Date
    Jan 2005
    Posts
    20
    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

  2. #2
    Super Contributor jplauril's Avatar
    Join Date
    Dec 2004
    Posts
    643
    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.

  3. #3
    Registered User pollyp's Avatar
    Join Date
    Jan 2005
    Posts
    20
    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

  4. #4
    Super Contributor jplauril's Avatar
    Join Date
    Dec 2004
    Posts
    643
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved