Comments (7)
Thank you for raising the issue. Debugging this is going to be fun :)
Are you able to isolate the Python code that's causing the issue and share it?
from tapo.
Thank you for raising the issue. Debugging this is going to be fun :) Are you able to isolate the Python code that's causing the issue and share it?
Unfortunately stderr is only receiving this from the dying process
Thread 0x0000007fa31164c0 (most recent call first):
(no Python frame)
Fatal Python error: Segmentation fault
The code causing the segfault is attached here [removed]
from tapo.
OK, I might have found the cause. This little piece of python code is executed as a telegraf input plugin to collect data from the Tapos and forward it to an MQTT topic. The plugin was set to run every 5 secs with a 4 sec timeout if it does not complete in that time window. Normally the plugin takes less than 1 sec to complete, but in some occasions (network lags, device not ready) it goes past the timeout, and Telegraf preempts it with a SIGTERM. Just by increasing the timeout it's not happening again, and the problem is reproducible. If you have a Tapo P1XX device, just execute it as a normal python program and send it a SIGTERM before it exits (probably you would need a sleep()). It may lack some graceful disposal of the threads created in by tokio upon a SIGTERM
from tapo.
Thank you for the update.
I was not able to replicate the issue without TaskGroups. Did you?
Have you tried handling the SIGTERM on the Python side and cancelling the TaskGroups?
PS: I removed the zip file you've attached because it looked like it contained your Tapo password. You might want to change it.
from tapo.
from tapo.
Hi, I tried with a SIGTERM handler to cancel the tasks but it fails in the same way. However, now I can get logged more details about the error
Thread 0x0000007f9df514c0 (most recent call first):
Signal 15 received. Cancelling tasks ...
Error unhandled errors in a TaskGroup (1 sub-exception)
Traceback (most recent call last):
File "/usr/local/bin/tapo-telegraf-multi-async.py", line 149, in
asyncio.run(main())
File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/local/bin/tapo-telegraf-multi-async.py", line 143, in main
if task.result() == "":
^^^^^^^^^^^^^
File "/usr/local/bin/tapo-telegraf-multi-async.py", line 109, in gen_influx_str_from_ip
p110 = await init_p110(ip)
^^^^^^^^^^^^^^^^^^^
File "/usr/local/bin/tapo-telegraf-multi-async.py", line 73, in init_p110
p110 = await client.p110(ip)
^^^^^^^^^^^^^^^^^^^^^
Exception: Tapo(Unknown(1003))
Signal 15 received. Cancelling tasks ...
thread 'tokio-runtime-worker' panicked at /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.20.3/src/gil.rs:199:21:
assertion left != right
failed: The Python interpreter is not initialized and the auto-initialize
feature is not enabled.
Consider calling pyo3::prepare_freethreaded_python()
before attempting to use Python APIs.
left: 0
right: 0
stack backtrace:
0: rust_begin_unwind
at ./rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at ./rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
4: parking_lot::once::Once::call_once_force::{{closure}}
5: parking_lot::once::Once::call_once_slow
6: pyo3::gil::GILGuard::acquire
7: <pyo3_asyncio::tokio::TokioRuntime as pyo3_asyncio::generic::Runtime>::spawn::{{closure}}
8: tokio::runtime::task::core::Core<T,S>::poll
9: tokio::runtime::task::harness::Harness<T,S>::poll
10: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
11: tokio::runtime::scheduler::multi_thread::worker::Context::run
12: tokio::runtime::context::set_scheduler
13: tokio::runtime::context::runtime::enter_runtime
14: tokio::runtime::scheduler::multi_thread::worker::run
15: <tokio::runtime::blocking::task::BlockingTask as core::future::future::Future>::poll
16: tokio::runtime::task::core::Core<T,S>::poll
Signal 15 received. Cancelling tasks ...
Signal 15 received. Cancelling tasks ...
Fatal Python error: Segmentation fault
from tapo.
Are you able to try out the suggested solution to use the pyo3 auto-initiatize feature?
from tapo.
Related Issues (20)
- P300 support HOT 3
- Support for security cameras HOT 3
- get_device_info broken for L900 HOT 2
- [info] How can i use this in a windows C# Application. HOT 1
- [Feature Request] Please add audio reactive lighting control HOT 1
- Is it mandatory to use the Hub? HOT 2
- P115 changing WI-FI HOT 5
- H100 initialization attempt returns error HOT 4
- Support client.getDeviceList HOT 4
- Example for doing things with devices accessed throung the hub HOT 1
- Local access to TAPO P110 for energy data HOT 10
- S500D support HOT 3
- cannot import 'LightHander' or 'ColorLightHandler' for typings HOT 3
- Meaning / correctness of timestamps of device.get_energy_data HOT 3
- Bug in hue/saturation and color_temperature code HOT 2
- ApiClient on AWS Lambda HOT 1
- ImportError: cannot import name 'ApiClient' from partially initialized module 'tapo' (most likely due to a circular import) HOT 2
- start_timestamp and export timestamp HOT 5
- Tapo: SessionTimeout HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tapo.