0

I created a Windows application in Python and the Kivy framework. The main feature of the app is to post the request on the server in API through a button. The server will send the task to a robot and will respond to my app in JSON format. Depending on the status of the robot, the server will give the data following it, and I will give the feedback to the user in color.

For example, the server response "taskStatus":"4"

I will display the green color, and if the server response number is "6" I will display the orange.

I try using the "thread" and "schedule" modules to test it. But it still makes the app crash. You can see my example code

from threading import Thread
    
   def post_device_status_background():
        api_url_get = "http://*.*.*.*:7000/ics/out/task/getTaskOrderStatus"
        data = {
            "areaId": "1",
            "deviceType": "0",
            "deviceCode": "khang0000"
        }
        try:
            response = requests.post(api_url_get, json=data)
            print("Device status:", response.json())
        except Exception as e:
            print(f"Error: {e}")
    
    def post_device_status(self, dt):
        Thread(target=post_device_status_background).start()
    
    Clock.schedule_interval(post_device_status, 10)

The main point of my question is how to always get the status of the robot after clicking the button and not make the app crash? Do you have any advice?

4
  • Hi. I would advise you not to share IP addresses of your applications publicly. I've submit an edit to your post about this. Regarding your question, are any errors shown when the app crashes? Commented Jan 20 at 16:53
  • Thanks for your edition. Because the app runs on Windows, the only error it shows to me is "Not responding.". Commented Jan 21 at 1:15
  • Have you tested the API response outside your application? For example, using postman or other software to test API responses. It seems to me the error is occuring on the API side. Commented Jan 21 at 11:44
  • The API response is ok. This error only shows up when I request too much from the server. If I request one by one , the application is still ok. I think the point is the structure system of my app. Because I don't know well about this field Commented Jan 22 at 14:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.