Create and use Class under asyncio context? But time.sleep() used?
Posted: Wed Aug 03, 2022 3:37 pm
Create and use Class under asyncio context? But time.sleep() used?
This maybe a general python question not unique to MicroPython, but since I am using said class on ESP and Pico, thought I would post it here. I have created a class that I plan or desire the flexibility to instance it both in an asyncio context and otherwise. I am using time.sleep() to delay the class execution of a specific method, and this is thread blocking for the given thread its is running on, ok, understood.
The question is, if this same class is in asyncio context, is time.sleep going to work, technically asyncio.sleep should be called no? To make sure the given asyncio event loop is serviced, right?
Is there a way to make a given class not context specific, i.e. under asyncio or not when used? Or do I really have to create two classes, one designed to work under asyncio and other that will be used outside of asyncio context?
This maybe a general python question not unique to MicroPython, but since I am using said class on ESP and Pico, thought I would post it here. I have created a class that I plan or desire the flexibility to instance it both in an asyncio context and otherwise. I am using time.sleep() to delay the class execution of a specific method, and this is thread blocking for the given thread its is running on, ok, understood.
The question is, if this same class is in asyncio context, is time.sleep going to work, technically asyncio.sleep should be called no? To make sure the given asyncio event loop is serviced, right?
Is there a way to make a given class not context specific, i.e. under asyncio or not when used? Or do I really have to create two classes, one designed to work under asyncio and other that will be used outside of asyncio context?