Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    May 2008

    wierd behaivor with thread

    hello, ive made a simple program that open a socket in a new thread and sends data to a server as a demon.

    im starting the thread when the app begins (t.start()), but misteriously the run function in the thread is executed when i
    exit my app ( if i have t.setDaemon(True) commented) .so, when i exit my app the run function on the thread begins , the app become stucked, but the thread is working and sending data and i cannot close the app and need to take of the battery of the phone for restarting.
    if i uncomment the t.setDaemon(True) the app finish but it never sends data to the server.

    Do anybody know why is happening this wierd behaivor? ive tried the same code in my computer and it works fine? Is this something specific of symbian?
    or pys60? im running pys60 on nokia 1.4.2



    import threading
    import httplib
    import urllib
    from socket import *
    from math import sqrt
    from graphics import *
    from random import *
    import graphics
    import appuifw
    import e32
    runnin= 1  
    class MiThread(threading.Thread):
        def __init__(self, num):
            self.num = num
            self.params = urllib.urlencode({'data': 3453, 'equis': 3123, 'ygri': 12444})
            self.headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
            self.conn = httplib.HTTPConnection("www.ketaplex.net")    
            self.apid = select_access_point()
            self.apo = access_point(self.apid)
            #myip= self.apo.ip()
        def envia(self):
             self.conn.request("POST", "/cgi-bin/grow_recibe.py", self.params, self.headers)
             self.response = self.conn.getresponse()        
        def run(self):
            self.s = socket(AF_INET, SOCK_STREAM)
            while runnin == 1:
    BLACK = (0, 0, 0)   
    WHITE = (255, 255, 255)
    GREEN = (255, 0, 255)
    RED = (255, 0, 0)
    coloryo= (255, 255, 0)
    appuifw.app.title=unicode('My Test App')
    def handle_redraw(rect):   
            if img: canvas.blit(img) 
    def quit():   
            global running   
            running = False
    appuifw.app.exit_key_handler = quit
    num_pixels = 100
    w, h = canvas.size   
    img = graphics.Image.new((w, h))   
    import time
    t = MiThread(0)
    #you need to have setdameon commented for making the thread works when you exit the app
    running = True  
    while running:
            img.point(( 100 ,100 ), outline = BLACK, width = 8)

  2. #2
    Regular Contributor
    Join Date
    May 2008

    Re: wierd behaivor with thread

    can anybody try the code please?
    and tell me if you get the same behaivor?

    it seems the main thread of my app or the main app has locked itself and it just unlock when it finish , so maybe thats why the function senddata from my thread begins working when i exit the app.

    any idea?
    maybe there another way of doing this? in python list they recommended to use events instead of threads.

    any hint would be appreciated;


Similar Threads

  1. S60 SDK 3rd edition FP1 Emulator problem
    By justteam in forum Symbian Tools & SDKs
    Replies: 14
    Last Post: 2010-03-23, 08:47
  2. console app running problem
    By xcompass in forum Symbian
    Replies: 3
    Last Post: 2009-05-08, 13:26
  3. error on "Emulator"
    By xmnlk in forum Symbian
    Replies: 3
    Last Post: 2008-05-22, 16:39
  4. Start S60 3rd emulator failure
    By zeusstar in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2006-10-08, 16:55
  5. Link errors when trying to Display bitmap
    By Bkc82 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2006-01-16, 22:46

Posting Permissions

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