request lib with async

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
user123lahal
 
Posts: 11
Joined: Mon Nov 15, 2021 8:39 am

request lib with async

Post by user123lahal »

Hi everyone, I am trying to do multitasking with async library. I am using stepper motors, UART for RFID and 24 bit ADC and one ethernet. I can do multitasking without ethernet ( I can run 2 stepper same time, two 24 bit ADC same time, 2 RFID reader same time.) I need to take datas from 24 bit ADC then post it to API.
When 2 24 bit ADC work same time the problem appears. For example first 24 bit ADC is reaches the target value lets say 500, when first 24 bit ADC reaches the 500, ethernet tries to send to API that value. Second 24 bit ADC might be reach 500 while ethernet trying to post to api.
When ethernet module trying to post first 24 bit ADC's value, It might be miss second 24 bit ADC's values. So I need to use await for request module too
When I try to use it like this ;

Code: Select all

JSON_URL = ("http://jsonplaceholder.typicode.com/todos/1")
response = await requests.get(JSON_URL)
print(response.json())
r = response.json()
It gives this;

Code: Select all

AttributeError: 'Response' object has no attribute '__await__'
Is there a way to add __await__ to response object ?

User avatar
danhalbert
 
Posts: 4686
Joined: Tue Aug 08, 2017 12:37 pm

Re: request lib with async

Post by danhalbert »

I have started working on an async version of the adafruit_requests library. I have the initial coding, but haven't tested it yet, and there have been some other more pressing tasks. It's hard to add without redoing the internals of the whole library, though much of the code stays the same.

So the answer is not yet, sorry, and I don't have a schedule for when this will be done, but it is in our plans.

User avatar
user123lahal
 
Posts: 11
Joined: Mon Nov 15, 2021 8:39 am

Re: request lib with async

Post by user123lahal »

danhalbert wrote:I have started working on an async version of the adafruit_requests library. I have the initial coding, but haven't tested it yet, and there have been some other more pressing tasks. It's hard to add without redoing the internals of the whole library, though much of the code stays the same.

So the answer is not yet, sorry, and I don't have a schedule for when this will be done, but it is in our plans.
Thank you, I am looking forward to it. If you release something like beta version I can use it and try it (I am not good at coding that much but at least I can use it in my project and try.)

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”