| | |
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: 557 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for bluetooth, obexftp, push, python
abrupt address advanced advice ajax aliased array avogadro backend beginner bluetooth c++ calculator celebration code compile copy corners cx-freeze def edit event examples excel exception file filename function google gui headset hints http images input internet ip itunes java jawbone launcher library linux list lists loop maze mobile mouse movingimageswithpygame mysqldb networking newb news opensource output parameters present print programming projects push py2exe pygame pyglet pyqt python rails random recursion recursive redirect return ruby rubyconf server shebang sqlite ssh string strings strip sum syntax table text threading tkinter tlapse tutorial ubuntu urllib urllib2 variable ventrilo wikipedia wordgame write wxpython xlwt






