求助!关于使用Blinker-py库发送实时数据时出现的问题-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 421|回复: 0

[求助] 求助!关于使用Blinker-py库发送实时数据时出现的问题

[复制链接]
发表于 2022-6-20 20:33 | 显示全部楼层 |阅读模式
本帖最后由 yinbing 于 2022-6-20 20:39 编辑

各位大神,我在树莓派4B上运行blinker-py库自带的实时数据示例(代码见图1)时,出现了图2所示报错,然后虽然程序仍能连上服务器,但无法响应APP实时数据请求(key已经检查过,设置正确)。我对python还不是非常熟悉,请大神们帮帮忙看看该如何解决这个问题。


环境:树莓派4B、raspberrypi os 32bit lite(debian11 bullseye)、python3.9。

图1  示例代码(文件名:blinker_realtime_test.py):
  1. # -*- coding: utf-8 -*-

  2. """
  3. 实时数据
  4. """

  5. __author__ = 'stao'

  6. import random

  7. from blinker import Device


  8. def generate_data():
  9.    return random.randint(1, 100)


  10. async def realtime_func(keys):
  11.    print("realtime func received {0}".format(keys))
  12.    for key in keys:
  13.        if key == "num-hid":
  14.            await device.sendRtData(key, generate_data)
  15.        elif key == "num-tid":
  16.            await device.sendRtData(key, generate_data)


  17. device = Device("xxxxxxxxx", realtime_func=realtime_func)

  18. if __name__ == '__main__':
  19.    device.run()
复制代码



图2  bash shell 报错:
  1. pi@raspberrypi:~/ydyp_dir/src_pi $ python blinker_realtime_test.py
  2. Exception in thread Thread-5:
  3. Traceback (most recent call last):
  4. File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
  5.    self.run()
  6. File "/usr/lib/python3.9/threading.py", line 892, in run
  7.    self._target(*self._args, **self._kwargs)
  8. File "/usr/local/lib/python3.9/dist-packages/blinker/device.py", line 170, in scheduler_run
  9.    self.scheduler.start()
  10. File "/usr/local/lib/python3.9/dist-packages/apscheduler/schedulers/background.py", line 35, in start
  11.    BaseScheduler.start(self, *args, **kwargs)
  12. File "/usr/local/lib/python3.9/dist-packages/apscheduler/schedulers/base.py", line 150, in start
  13.    self.add_executor(self._create_default_executor(), 'default')
  14. File "/usr/local/lib/python3.9/dist-packages/apscheduler/schedulers/base.py", line 762, in _create_default_executor
  15.    return ThreadPoolExecutor()
  16. File "/usr/local/lib/python3.9/dist-packages/apscheduler/executors/pool.py", line 53, in __init__
  17.    pool = concurrent.futures.ThreadPoolExecutor(int(max_workers), **pool_kwargs)
  18. File "/usr/lib/python3.9/concurrent/futures/__init__.py", line 49, in __getattr__
  19.    from .thread import ThreadPoolExecutor as te
  20. ImportError: cannot import name 'ThreadPoolExecutor' from partially initialized module 'concurrent.futures.thread' (most likely due to a circular import) (/usr/lib/python3.9/concurrent/futures/thread.py)
  21. 2022-06-20 20:17:16.690 | SUCCESS  | blinker.device:device_init:225 - Device auth successful...
  22. 2022-06-20 20:17:16.692 | INFO     | blinker.device:_cloud_heartbeat:248 - Send cloud heartbeat
  23. 2022-06-20 20:17:16.703 | INFO     | blinker.httpclient:cloud_heartbeat:128 - http cloud heartbeat
  24. 2022-06-20 20:17:16.990 | INFO     | blinker.mqttclient:_on_connect:46 - Connect to broker from mqtt
  25. 2022-06-20 20:17:16.991 | SUCCESS  | blinker.mqttclient:_on_connect:48 - Broker connected...
  26. 2022-06-20 20:17:16.993 | SUCCESS  | blinker.device:_receiver:384 - Receiver ready...
复制代码


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-12-1 04:36 , Processed in 0.069022 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表