cthuun / python-xbee

Automatically exported from code.google.com/p/python-xbee
MIT License
1 stars 0 forks source link

If the callback thread ends due to an exception, XBee.halt() will wait forever. #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add a callback when creating an XBee object.
2. Unplug your XBee from the computer, causing an exception in 
XBee._wait_for_frame.
3. Arrange for your code to call halt() on your XBee object.

What is the expected output? What do you see instead?

The halt() method should return immediately (the thread has long since ended by 
exception). Instead, halt() waits forever for the _thread_quit event to be set.

What version of the product are you using? On what operating system?

2.0.0, Ubuntu 11.10

Please provide any additional information below.

I am attaching a patch that corrects this problem.

Original issue reported on code.google.com by alan.way...@gmail.com on 12 Apr 2012 at 11:22

Attachments:

GoogleCodeExporter commented 9 years ago
That's a good catch. I will include your patch ASAP. Thank you!

Original comment by pmalms...@gmail.com on 13 Apr 2012 at 9:17

GoogleCodeExporter commented 9 years ago
Actually, I think my patch is probably not the right way to go.  The proper way 
to wait for a thread to exit is to join it, which will work no matter how the 
thread exited.  Take a look at this commit instead:
http://code.google.com/r/alanwaynejohnson-xbee/source/detail?r=801f265d9b237d525
d47d05b3302689d16346b08

I've just removed the threading.Event, and I'm using Thread.join() to wait for 
the thread to exit.

Original comment by alan.way...@gmail.com on 15 Apr 2012 at 2:46

GoogleCodeExporter commented 9 years ago
That's a good point; thanks for the update.

And thanks for the server-size clone; I'll go ahead and pull it in right now.

Original comment by pmalms...@gmail.com on 16 Apr 2012 at 7:16

GoogleCodeExporter commented 9 years ago
Fixed as of revision 801f265d9b23.

Original comment by pmalms...@gmail.com on 16 Apr 2012 at 7:30