Skip to content

Subprocess 丟出 exception 導致程式整個 halt 住 #41

Description

@vava24680
  • 問題描述:當一開始 sa.py 中的 endpoint 打錯導致 requests 無法正常將 request 送到 EC 時,subprocess 會拋出 exception 但整個程式並不會中止而是 halt 住,需要多按一次 CTRL-C 才能終止
  • 執行環境:
    • OS: Debian 10
    • Python: CPython 3.7.3
    • iottalk-py version: 2.3.0
    • SA file which can re-produce the siuation:
      import random
      
      from iottalkpy.dan import NoData
      
      ### The registeration api url, you can use IP or Domain.
      # api_url = 'https://iottalk2.tw/csm'  # default
      api_url = 'http://GG/csm'  # with URL prefix
      # api_url = 'http://localhost:9992/csm'  # with URL prefix + port
      
      ### [OPTIONAL] If not given or None, server will auto-generate.
      device_name = 'Dummy_Test'
      
      ### [OPTIONAL] If not given or None, DAN will register using a random UUID.
      ### Or you can use following code to use MAC address for device_addr.
      from uuid import getnode
      # device_addr = "{:012X}".format(getnode())
      # device_addr = "..."
      
      ### [OPTIONAL] If the device_addr is set as a fixed value, user can enable
      ### this option and make the DA register/deregister without rebinding on GUI
      # persistent_binding = True
      
      ### [OPTIONAL] If not given or None, this device will be used by anyone.
      # username = 'myname'
      
      ### The Device Model in IoTtalk, please check IoTtalk document.
      device_model = 'Dummy_Device'
      
      ### The input/output device features, please check IoTtalk document.
      idf_list = ['Dummy_Sensor']
      odf_list = ['Dummy_Control']
      
      ### Set the push interval, default = 1 (sec)
      ### Or you can set to 0, and control in your feature input function.
      push_interval = 10  # global interval
      interval = {
          'Dummy_Sensor': 3,  # assign feature interval
      }
      
      
      def on_register(self):
          print('Register successfully')
      
      
      def Dummy_Sensor():
          return random.randint(0, 100)
      
          # Or you want to return nothing.
          # Note that the object `None` is treated as normal data in IoTtalk
          #
          # return NoData
      
      
      def Dummy_Control(data):  # data is a list
          print(str(data[0]))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions