Search found 84 matches

by Jim.S
Sat May 12, 2018 7:40 pm
Forum: General Discussion and Questions
Topic: uasyncio: best way to write to a file from a coroutine
Replies: 9
Views: 6718

Re: uasyncio: best way to write to a file from a coroutine

Of more interest to my purpose is the ability to terminate specific coroutines. I discovered that Cancellable coroutines can be assigned to groups in their construction , see the example code below, but specifically loop.create_task(asyn.Cancellable(file_write_append, 'async_test.txt', group='a' )()...
by Jim.S
Thu May 10, 2018 8:04 pm
Forum: General Discussion and Questions
Topic: uasyncio: best way to write to a file from a coroutine
Replies: 9
Views: 6718

Re: uasyncio: best way to write to a file from a coroutine

Wow, I'm amazed that the cancellable option gives such a neat solution. It is interesting that the only essential differences between my original naive code and the cancellable version, without the explicit try except block, is the addition of the @asyn.cancellable decorator and the use of await asy...
by Jim.S
Wed May 09, 2018 9:04 pm
Forum: General Discussion and Questions
Topic: uasyncio: best way to write to a file from a coroutine
Replies: 9
Views: 6718

Re: uasyncio: best way to write to a file from a coroutine

Figuring out how to use the synchronisation primitives was fun. Appending works well [open(filename, 'a')], but as suggested by the name, it will append to that file on subsequent runs of the code. Use of barriers to synchronise the termination of the event loop with the closing of the file is more ...
by Jim.S
Tue May 08, 2018 8:43 pm
Forum: General Discussion and Questions
Topic: uasyncio: best way to write to a file from a coroutine
Replies: 9
Views: 6718

uasyncio: best way to write to a file from a coroutine

I am writing a data logger that uses one coroutine to write data continuously to a file and another coroutine to terminate the event loop. I am finding that if the loop is terminated before the "with open('filename') as f" loop completes, the file is never closed. The code below shows the essential ...
by Jim.S
Sat Apr 21, 2018 4:12 pm
Forum: Programs, Libraries and Tools
Topic: uasyncio: number of tasks in the event loop
Replies: 3
Views: 3083

Re: uasyncio: number of tasks in the event loop

Thanks @Pythoncoder, works nicely. But anyone having problems getting it to work should make sure they are using uasyncio 2.0 and hence the latest pyboard firmware (which we should all be doing anyway!). My first attempt failed because I was using uasyncio 1.0. And it is my understanding that uasync...
by Jim.S
Thu Apr 19, 2018 4:03 pm
Forum: General Discussion and Questions
Topic: Problem using upip and micropip.py
Replies: 5
Views: 7991

Re: Problem using upip and micropip.py

Thanks @Pythoncoder, that makes me feel a whole lot less stupid!
by Jim.S
Thu Apr 19, 2018 6:37 am
Forum: General Discussion and Questions
Topic: Problem using upip and micropip.py
Replies: 5
Views: 7991

Problem using upip and micropip.py

I am trying to download the latest version of uasyncio using upip but keep running into the same error. I feel I am doing something obviously wrong but cant figure it out on my own. (What is really annoying is that I got this to work in March but can't figure out what I did correct!) output from mic...
by Jim.S
Sun Apr 15, 2018 12:00 pm
Forum: Programs, Libraries and Tools
Topic: uasyncio: number of tasks in the event loop
Replies: 3
Views: 3083

uasyncio: number of tasks in the event loop

Is there a simple way to get the number of tasks queued in the event loop?

I think I have written a program that adds a new task every time one task is run, and need to check my understanding of what is happening.
by Jim.S
Wed Apr 11, 2018 8:32 pm
Forum: MicroPython pyboard
Topic: uasyncio and SIM800 UART
Replies: 10
Views: 7846

Re: uasyncio and SIM800 UART

Asynchronous programming requires a rather different mindset but once you've got the hang of it, it's magic ;) @pythoncoder I would thoroughly agree with this. I am just starting to get my head around uasyncio and the asyn.Event class in particular. For me, it makes the software feel more like hard...
by Jim.S
Sat Mar 24, 2018 7:46 pm
Forum: Programs, Libraries and Tools
Topic: uasyncio: Example of the the use of aswitch classes
Replies: 4
Views: 3709

Re: uasyncio: Example of the the use of aswitch classes

... actually I dont think I need to get my soldering iron out to run this code! I have just realised that with these new fangled microcontrollers like the STM32 they actually have the pull up and pull down resistors built in! so you don’t have to solder up a little circuit with a switch and a 10k pu...