| Reply | « Previous Thread | Next Thread » |
|
Hi,
how can I kill a thread that does not respond anymore? I start the the thread like this: Code:
thread.start_new_thread(bt_scan,()) |
|
Here's quite a thread about thread: http://discussion.forum.nokia.com/fo...d.php?t=118547
What do you mean by "does not respond"? whatever happens happens |
|
Ok, I call the finddevices() function from the lightblue module to do a bluetooth scan. Normaly this function delivers after 10-30 sec a list with all found BT devices, but sometimes it does not deliver anything, it just hangs and the thread cannot close automatically.
I thought to ta start the finddevices function in the second thread and wait at least 120 sec and then close the first thread and I thought that with closing the first thread, the second thread would also close but it doesn't. os.getpid() deliverers the same id for each thread, so it could not be killed. How can I kill or abort the hanging thread? Code:
def bt_mainthread(): global bt_busy thread.start_new_thread(bt_scan,()) time.sleep(1) while bt_busy and (bt_scan_time < 120): time.sleep(1) if bt_scan_time > 119: blues.off() time.sleep(5) blues.on() time.sleep(5) bt_busy = False def bt_scan(): global btscan, btquery_list, bt_busy, bt_scan_time bt_busy = True bt_scan_time = 0 try: btscan = lightblue.finddevices() except: btscan = [] btquery_list = [] for i in range(len(btscan)): btquery_list.append(query_bt(btscan[i])) bt_busy = False def loop(): global bt_busy, bt_scan_time if config['BT_SCAN'] > 0 and not bt_busy: bti += 1 if (bti > config['BT_SCAN']*1) and not bt_busy: bti = 0 thread.start_new_thread(bt_mainthread,()) if bt_busy: bt_block += 1 bt_scan_time += 1 |
|
Did you come up with a solution to this?
|
| phonegnome |
| View Public Profile |
| Find all posts by phonegnome |
|
PyS60 does not have a function for this. But looks like it's possible on Symbian:
http://www.symbian.com/Developer/tec...ead%3a%3aKill() So native extension is needed. Mikko Ohtamaa Twinapex Research http://www.twinapex.com |
|
Hello,
I have problems killing a thread in python. The whole app. seems to crash. ![]() I tried this: Code:
import thread
def subthread():
global bla1, bla2, bla3
while subthread_active:
# do something
# start the subthread
subthread_active = True
thread.start_new_thread(subthread, ())
# stop the subthread
subthread_active = False
![]() |
|
Quote:
Mikko Ohtamaa Twinapex Research http://www.twinapex.com |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| console app running problem | xcompass | General Symbian C++ | 3 | 2009-05-08 14:26 |
| S60 SDK 3rd edition FP1 Emulator problem | justteam | Symbian Tools & SDKs | 12 | 2008-03-04 05:44 |
| Kill Thread Problem | westweb | General Symbian C++ | 0 | 2007-08-01 19:55 |
| Error on "emulator" | zhang2008 | General Symbian C++ | 2 | 2006-10-08 17:55 |
| Link errors when trying to Display bitmap | Bkc82 | Symbian Media (Graphics & Sounds) | 1 | 2006-01-16 23:46 |