question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot exit thread with device.close()

See original GitHub issue

I started with python-xbee/examples/communication/ReceiveDataPollingSample/ReceiveDataPollingSample.py example by adding


while True:
            xbee_message = device.read_data()
            if xbee_message is not None:
                print("From %s >> %s" % (xbee_message.remote_device.get_64bit_addr(),
                                         xbee_message.data.decode()))
                device.close()
                break

The code hang after received a message even though I tried to close device and break from while loop. I have to ctrl-c to exit

Then I got below message:

Exception ignored in: <module 'threading' from '/usr/lib/python3.5/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 1288, in _shutdown
    t.join()
  File "/usr/lib/python3.5/threading.py", line 1054, in join
    self._wait_for_tstate_lock()
  File "/usr/lib/python3.5/threading.py", line 1070, in _wait_for_tstate_lock
    elif lock.acquire(block, timeout):
KeyboardInterrupt

Any suggestion on how I can solve this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
hgonzaleDigicommented, Apr 13, 2018

Hello all,

As @FRVisser said, this issue has been resolved in master, but a new release has not been generated. This means that PyPI does not have the latest packaged code to upgrade the library trhough pip.

We are working on generating a new version of the library to distribute through pip, and it will be released shortly.

In the meantime, if any of you needs the changes from master, you can update your python distributions manually. To do so:

  1. Get the code from master.
  2. In the root directory you will see a “digi” directory.
  3. Go to your python distribution (<path_to_python3.x>/Lib/site-packages)
  4. If the “digi” directory exists there from a previous distribution, uninstall it through pip, or remove it manually.
  5. Add the “digi” directory just copied from master.

These steps should do it for you. Again, we are planning to do the official release soon, which would allow you to upgrade your library thrugh pip: pip install --upgrade digi-xbee

0reactions
rubenmoralcommented, Jul 11, 2018

Closing this issue since the fix is already included in the latest release: https://github.com/digidotcom/python-xbee/releases.

To update the library through pip, run pip install digi-xbee --upgrade.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot exit thread with device.close() · Issue #33 - GitHub
I started with python-xbee/examples/communication/ReceiveDataPollingSample/ReceiveDataPollingSample.py example by adding while True: ...
Read more >
Why does sys.exit() not exit when called inside a thread in ...
The docs for sys.exit() state that the call should exit from Python. I can see from the output of this program that "post...
Read more >
Killing threads in Java - GeeksforGeeks
A thread is automatically destroyed when the run() method has completed. But it might be required to kill/stop a thread before it has ......
Read more >
An Intro to Threading in Python
In this intermediate-level tutorial, you'll learn how to use threading in your Python programs. You'll see how to create threads, how to coordinate...
Read more >
Processes and threads overview - Android Developers
To fix this problem, Android offers several ways to access the UI thread from other threads. Here is a list of methods that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found