uasyncio get_event_loop() methods

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

uasyncio get_event_loop() methods

Post by ajie_dirgantara » Wed Oct 18, 2017 7:54 am

when I do this in REPL :


>>>import uasyncio
>>>loop = uasyncio.get_event_loop()


>>> loop. <--press Tab-->
__init__ remove_reader wait __qualname__
add_writer remove_writer add_reader __module__

It only shown above method? unlike usual upy modules, I've got all it class member.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: uasyncio get_event_loop() methods

Post by pythoncoder » Wed Oct 18, 2017 8:42 am

I think something is wrong with your installation. I see

Code: Select all

MicroPython v1.9.2-69-gcc7fece on 2017-09-12; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>> 
>>> import uasyncio
>>> loop = uasyncio.get_event_loop()
>>> dir(loop)
['__init__', 'remove_reader', 'wait', '__qualname__', 'add_writer', 'remove_writer', 'add_reader', '__module__', 'q', 'poller', 'objmap']
>>> loop.
__init__        remove_reader   wait            __qualname__
add_writer      remove_writer   add_reader      __module__
>>> 
Note that get_event_loop returns a PollEventLoop object, which is subclassed from EventLoop. It is an oddity of MicroPython that methods of the base class (such as create_task) aren't listed when Tab is pressed or dir() is targeted at a subclass instance.
Peter Hinch
Index to my micropython libraries.

ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

Re: uasyncio get_event_loop() methods

Post by ajie_dirgantara » Wed Oct 18, 2017 10:44 am

pythoncoder wrote:
Wed Oct 18, 2017 8:42 am
I think something is wrong with your installation. I see

Code: Select all

MicroPython v1.9.2-69-gcc7fece on 2017-09-12; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>> 
>>> import uasyncio
>>> loop = uasyncio.get_event_loop()
>>> dir(loop)
['__init__', 'remove_reader', 'wait', '__qualname__', 'add_writer', 'remove_writer', 'add_reader', '__module__', 'q', 'poller', 'objmap']
>>> loop.
__init__        remove_reader   wait            __qualname__
add_writer      remove_writer   add_reader      __module__
>>> 
Note that get_event_loop returns a PollEventLoop object, which is subclassed from EventLoop. It is an oddity of MicroPython that methods of the base class (such as create_task) aren't listed when Tab is pressed or dir() is targeted at a subclass instance.
I think our REPL output is the same. here is my output :

Code: Select all

>>> import uasyncio
>>> loop=uasyncio.get_event_loop()
>>> dir(loop)
['__init__', 'remove_reader', 'wait', '__qualname__', 'add_writer', 'remove_writer', 'add_reader', '__module__', 'q', 'poller', 'objmap']
>>> loop.
__init__        remove_reader   wait            __qualname__
add_writer      remove_writer   add_reader      __module__
>>>
I follow your instruction here :

viewtopic.php?f=16&p=22487#p22495

Post Reply