py_websockets_bot bot.update() on Mac OSX

If you need technical help with anything you've bought from Dawn Robotics, please post here.

py_websockets_bot bot.update() on Mac OSX

Postby SimonBirrell » Fri Dec 19, 2014 10:30 am

Hi,

I'm running a Python app that interfaces with py_websockets_bot on Mac OS X. Most things are working fine, but I've run into a problem with bot.update(). Calling it generates the following exception:

Traceback (most recent call last):
File "./scratch_to_bot.py", line 210, in <module>
connect_to_scratch_and_stream_commands_to_bot()
File "./scratch_to_bot.py", line 199, in connect_to_scratch_and_stream_commands_to_bot
robot.update()
File "./scratch_to_bot.py", line 180, in update
self.bot.update()
File "/Library/Python/2.7/site-packages/py_websockets_bot/__init__.py", line 687, in update
num_items_to_process = streaming_data.data_queue.qsize()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/queues.py", line 139, in qsize
return self._maxsize - self._sem._semlock._get_value()
NotImplementedError

The error is actually in the Python framework. Digging a bit, I found the following:

https://docs.python.org/2/library/multiprocessing.html

qsize()
Return the approximate size of the queue. Because of multithreading/multiprocessing semantics, this number is not reliable.

Note that this may raise NotImplementedError on Unix platforms like Mac OS X where sem_getvalue() is not implemented.


so it appears that the current implementation of update() is incompatible with Mac OS X.

I'm looking for a workaround - my main interest in update() is to keep the camera streaming.

Any ideas?

Thanks

Simon
SimonBirrell
 
Posts: 6
Joined: Fri Dec 19, 2014 9:40 am

Re: py_websockets_bot bot.update() on Mac OSX

Postby Alan » Mon Dec 22, 2014 8:20 pm

Hi Simon,

Thank you for reporting this. I don't have a Mac available to test our code so any bug reports that come from Mac users are very much appreciated.

If you haven't already found a workaround (I'm guessing now that VLC was the workaround?) could you please try changing the code to something like
Code: Select all
MAX_NUM_ITEMS_TO_PROCESS = 10         # Set this to a value that stops update() from taking too long...
num_items_to_process = MAX_NUM_ITEMS_TO_PROCESS


The following while loop should still exit cleanly if the queue contains less than
MAX_NUM_ITEMS_TO_PROCESS, and hopefully that will work around any nasty platform bugs.

Regards

Alan
Alan
Site Admin
 
Posts: 311
Joined: Fri Jun 14, 2013 10:09 am


Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest