Problems (#1) - Python Threading (#91) - Message List

Python Threading
 unsolved

I'm trying to put the discovery process into a threaded loop so I can always be looking for the wiimote while my app is running. The problem I'm having is that as soon as cwiid.Wiimote() is hit it blocks until it fails or tries again. Here's what I've got:

import cwiid,time

class test(threading.Thread):

def run(self):

self.connected = False

self.running = True

while self.running;

while not self.connected:

try:

mymote = cwiid.Wiimote()

self.connected = True:

except:

self.connected = False

time.sleep(.5)

if self.connected:

mymote.led = 1

try:

mymote.request_status()

except:

self.connected = False

test().start()

and every time, as soon as it hits Wiimote() it blocks. Any suggestions?

  • Message #24379

    The way BlueZ is written, it's got to block for some amount of time. Currently that time is fixed, although, it could be altered, or another function created to allow a variable timeout period. Would that fit your needs?

    • Message #24389

      Well I can't let my entire program block constantly as its searching for wiimotes... I need some way to thread the block if possible. I don't mind the timeout as long as it doesn't make my entire app stop every loop of the search.

Attachments

No attachments created.