| | |
help with threads and obexftp push
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2009
Posts: 1
Reputation:
Solved Threads: 0
Hello all,
I recently started using Python to test a Bluetooth Push application prototype and everything was working great until threading. I wonder if someone knows how to start multiple threads of connectpush() with Obexftp running under Linux?
So far with the code below I have to wait until the first client connection gets close to start the next connection and I need to start many push connections at once.
The strange part is that the threads are working for obexftp.browsebt() method so I get push channels in every
thread or maybe it's because we don't need to accept or deny a connection to read a push channel in a Bluetooth device.
Thank you for your help
Luis S.
I recently started using Python to test a Bluetooth Push application prototype and everything was working great until threading. I wonder if someone knows how to start multiple threads of connectpush() with Obexftp running under Linux?
So far with the code below I have to wait until the first client connection gets close to start the next connection and I need to start many push connections at once.
The strange part is that the threads are working for obexftp.browsebt() method so I get push channels in every
thread or maybe it's because we don't need to accept or deny a connection to read a push channel in a Bluetooth device.
Thank you for your help
Luis S.
Python Syntax (Toggle Plain Text)
import time import obexftp import threading def discover(): cli = obexftp.client(obexftp.BLUETOOTH) clientes = cli.discover() radios = len(clientes) cli.disconnect() cli.delete return clientes class pushfile(threading.Thread): def __init__(self,mac): threading.Thread.__init__(self) self.mac = mac def run(self): cli = obexftp.client(obexftp.BLUETOOTH) canal = obexftp.browsebt(self.mac,obexftp.PUSH) time.sleep(1) print "Connected to push channel: ",canal," of: ",self.mac time.sleep(1) cli.connectpush(self.mac,canal,'hci2') print "Sending file to: %s" % self.mac enviado = cli.put_file("filename.jpg") if enviado == 1: print "Send to: %s" % self.mac cli.disconnect() cli.delete time.sleep(1) start = time.time() devicelist = [] dispositivos = discover() radios = len(dispositivos) print dispositivos print radios for i in range(radios): mac = dispositivos[i] t = pushfile(mac) devicelist.append(t) t.start() for push in devicelist: push.join() print "Thread ended for: ",push.mac print "Elapsed Time: %s" % (time.time() - start)
![]() |
Similar Threads
- I want google to index forum threads (Search Engine Optimization)
- Threads? help (Python)
- Threads! (C++)
- IE won't let me access threads. Could someone email me a solution please? (Web Browsers)
Other Threads in the Python Forum
- Previous Thread: a simple math problem
- Next Thread: My first oop project - can my code be simplified?
Views: 562 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for bluetooth, obexftp, push, python
accessdenied aliph anti apax avogadro bash beginner bluetooth book c++ client code console convert csv cturtle curved cx-freeze data def development dynamic edit editing enter examples excel file filename function gadgets generator gui halp homework ideas iframe infosec input internet java keyboard leftmouse library linux list lists loan microsoft mobile module mysql news numbers obexftp parameters present prime print programming projects py2exe pygame pygtk pyopengl python random raw_input read recursive redirect remote reverse ruby rubyconf silverlight simple socket string sudokusolver table terminal text thread threading time tkinter tooltip tutorial ubuntu update urllib urllib2 variable verify voip web-scrape whileloop wordgame wxpython






