Search found 32 matches

by cemox
Wed May 06, 2020 1:42 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 11
Views: 786

Re: asyncio.start_server example (!)

Thank you Jomas, waiting for the blank lines solved both the server and the client side communication problems :) At last it worked ! Putting a small delay right after writer.awrite(resp) , solved the problem. The whole working code is : import uasyncio as asyncio import utime async def serve(reader...
by cemox
Wed May 06, 2020 12:22 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 11
Views: 786

Re: asyncio.start_server example (!)

I will change the utime.sleep() to asyncio.sleep(). @pythoncoder and @jomas, thank you both for your comments. I can listen to the radio channels pretty well now. Now, I have another problem. I want to control my web radio from a remote web browser, my esp8266 board now works as a (AP) server and (S...
by cemox
Tue May 05, 2020 3:59 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 11
Views: 786

Re: asyncio.start_server example (!)

At last it worked ! Putting a small delay right after writer.awrite(resp) , solved the problem. The whole working code is : import uasyncio as asyncio import utime async def serve(reader, writer): t = utime.ticks_ms() resp = b"HTTP/1.0 200 OK\r\n\r\n" + "Ticks = {TICKS}\r\n".format(TICKS=t) l = awai...
by cemox
Tue May 05, 2020 3:43 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 11
Views: 786

Re: asyncio.start_server example (!)

Thank you for your comments Peter. Of course, I did not want to send the same sentence to the client 100 times. I noticed that it woks, if I do that. In your code, if I change the iteration to 5 for example, it doesn't work either: Browser says: "Safari Cannot Open the Page Because the Network Conne...
by cemox
Tue May 05, 2020 1:40 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 11
Views: 786

Re: asyncio.start_server example (!)

Things getting more and more interesting. The code blow works, sending http header hundred times, when I change the multiplier to, say, 10, it doesn't work. Do you think it is a bug? import uasyncio as asyncio import utime async def serve(reader, writer): t = utime.ticks_ms() resp = b"HTTP/1.0 200 O...
by cemox
Tue May 05, 2020 9:07 am
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 11
Views: 786

Re: asyncio.start_server example (!)

Thank you Peter, I will check PicoWeb. I am glad that I did not ask a stupid question :)
by cemox
Mon May 04, 2020 5:53 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 11
Views: 786

Re: asyncio.start_server example (!)

I also noticed that the connections is somehow continues (or suspended), google chrome inspector says
CATION: request is not finished yet
Screenshot from 2020-05-04 19-14-54.png
Screenshot from 2020-05-04 19-14-54.png (83.79 KiB) Viewed 569 times
by cemox
Sun May 03, 2020 8:31 pm
Forum: General Discussion and Questions
Topic: asyncio.start_server example (!)
Replies: 11
Views: 786

asyncio.start_server example (!)

I am trying to write a simple asyncio.start_server example, but it doesn't function properly. import uasyncio as asyncio async def handle_echo(reader, writer): # while (True): data = await reader.read(128) if (data): message = data.decode() addr = writer.get_extra_info('peername') print("Received %r...
by cemox
Sun May 03, 2020 4:29 am
Forum: General Discussion and Questions
Topic: uasyncio : Cancelling a task
Replies: 5
Views: 429

Re: uasyncio : Cancelling a task

Thanks Peter, I did exactly what you said and it works :). Something like this:

Code: Select all

playTask = asyncio.create_task(play(url1, port1))
and in change_station coro:

Code: Select all

async def changeChannel():
	playTask.cancel()
        playTask = asyncio.create_task(play(url2, port2))
by cemox
Sat May 02, 2020 9:52 am
Forum: General Discussion and Questions
Topic: uasyncio : Cancelling a task
Replies: 5
Views: 429

Re: uasyncio : Cancelling a task

Thanks Peter. Actually, what I am trying to do is to change the url of of a connection (web radio). async def play(url, port): global buff global bufferfull _, _, host, path = url.split('/', 3) print(host, path) addr = socket.getaddrinfo(host, port)[0][-1] reader, writer = await asyncio.open_connect...