Re: Using a background thread with asyncio/futures with flask

2024-03-24 Thread Frank Millman via Python-list
On 2024-03-23 3:25 PM, Frank Millman via Python-list wrote: It is not pretty! call_soon_threadsafe() is a loop function, but the loop is not accessible from a different thread. Therefore I include a reference to the loop in the message passed to in_queue, which in turn passes it to out_queue

Re: Using a background thread with asyncio/futures with flask

2024-03-23 Thread Frank Millman via Python-list
s the same issue: `app.py` ``` import asyncio import threading import time from queue import Queue in_queue = Queue() out_queue = Queue() def worker():     print("worker started running")     while True:     future = in_queue.get()     print(f"worker

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Mark Bourne via Python-list
Thomas Nyberg wrote: Hi, Yeah so flask does support async (when installed with `pip3 install flask[async]), but you are making a good point that flask in this case is a distraction. Here's an example using just the standard library that exhibits the same issue: `app.py` ``` import as

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Dieter Maurer via Python-list
dieter.mau...@online.de wrote at 2024-3-22 18:28 +0100: >Thomas Nyberg wrote at 2024-3-22 11:08 +0100: >> ... `future` use across thread boundaries ... >> Here's an example using just the standard library that >> exhibits the same issue: > ... >For use across thread boundaries, you likely will use

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Dieter Maurer via Python-list
Thomas Nyberg wrote at 2024-3-22 11:08 +0100: > ... `future` use across thread boundaries ... > Here's an example using just the standard library that > exhibits the same issue: I think all `asyncio` objects (futures, tasks, ...) are meant to be used in a single thread. If you u

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Frank Millman via Python-list
ed it and it did not work. I am not sure, but I think the problem is that you have a mixture of blocking and non-blocking functions. Here is a version that works. However, it is a bit different, so I don't know if it fits your use case. I have replaced the threads with background asynci

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Frank Millman via Python-list
problem is that you have a mixture of blocking and non-blocking functions. Here is a version that works. However, it is a bit different, so I don't know if it fits your use case. I have replaced the threads with background asyncio tasks. I have replaced instances of queue.Queue w

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Lars Liedtke via Python-list
policy https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php Am 22.03.24 um 08:58 schrieb Chris Angelico via Python-list: On Fri, 22 Mar 2024 at 18:35, Lars Liedtke via Python-list <mailto:python-list@python.org> wrote: Hey, As far as I know (might be old news) flask does n

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Frank Millman via Python-list
`app.py` ``` import asyncio import threading import time from queue import Queue from flask import Flask in_queue = Queue() out_queue = Queue() def worker():     print("worker started running")     while True:     future = in_queue.get()     print(f"worker got future: {futu

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Thomas Nyberg via Python-list
Hi, Yeah so flask does support async (when installed with `pip3 install flask[async]), but you are making a good point that flask in this case is a distraction. Here's an example using just the standard library that exhibits the same issue: `app.py` ``` import asyncio import thre

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Chris Angelico via Python-list
On Fri, 22 Mar 2024 at 18:35, Lars Liedtke via Python-list wrote: > > Hey, > > As far as I know (might be old news) flask does not support asyncio. > > You would have to use a different framework, like e.g. FastAPI or similar. > Maybe someone has already written "flask

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Lars Liedtke via Python-list
Hey, As far as I know (might be old news) flask does not support asyncio. You would have to use a different framework, like e.g. FastAPI or similar. Maybe someone has already written "flask with asyncio" but I don't know about that. Cheers Lars Lars Liedtke Lead Developer

Using a background thread with asyncio/futures with flask

2024-03-20 Thread Thomas Nyberg via Python-list
Hello, I have a simple (and not working) example of what I'm trying to do. This is a simplified version of what I'm trying to achieve (obviously the background workers and finalizer functions will do more later): `app.py` ``` import asyncio import threading import time from qu

Re: Python 3.9 asyncio: Task cancel() throws asyncio.exceptions.CancelledError instead of asyncio.CancelledError

2023-04-03 Thread Clint Olsen
On Friday, March 31, 2023 at 5:51:33 PM UTC-7, Chris Angelico wrote: > Can you confirm that it is indeed failing to catch the exception? Try this: > > except asyncio.CancelledError: > print("Cancelled correctly") > > followed by the same type checking from above. Since the ID is the > same, I

Re: Python 3.9 asyncio: Task cancel() throws asyncio.exceptions.CancelledError instead of asyncio.CancelledError

2023-03-31 Thread Chris Angelico
On Sat, 1 Apr 2023 at 11:42, Clint Olsen wrote: > > On Friday, March 31, 2023 at 4:14:51 PM UTC-7, Chris Angelico wrote: > > Okay, so that deals with the part from the subject line, leaving a > > slightly different problem: The caught exception is not of the same > > type as you were expecting. Fi

Re: Python 3.9 asyncio: Task cancel() throws asyncio.exceptions.CancelledError instead of asyncio.CancelledError

2023-03-31 Thread Clint Olsen
On Friday, March 31, 2023 at 4:14:51 PM UTC-7, Chris Angelico wrote: > Okay, so that deals with the part from the subject line, leaving a > slightly different problem: The caught exception is not of the same > type as you were expecting. First question: Can you reproduce the > issue on command?

Re: Python 3.9 asyncio: Task cancel() throws asyncio.exceptions.CancelledError instead of asyncio.CancelledError

2023-03-31 Thread Chris Angelico
On Sat, 1 Apr 2023 at 10:05, Clint Olsen wrote: > > On Friday, March 31, 2023 at 3:23:24 PM UTC-7, Chris Angelico wrote: > > On Sat, 1 Apr 2023 at 09:19, Clint Olsen wrote: > > > Attempting to catch asyncio.CancelledError or asyncio.CancelledError does > > > not work. The function in question lo

Re: Python 3.9 asyncio: Task cancel() throws asyncio.exceptions.CancelledError instead of asyncio.CancelledError

2023-03-31 Thread Clint Olsen
On Friday, March 31, 2023 at 3:23:24 PM UTC-7, Chris Angelico wrote: > On Sat, 1 Apr 2023 at 09:19, Clint Olsen wrote: > > Attempting to catch asyncio.CancelledError or asyncio.CancelledError does > > not work. The function in question looks like: > >>> asyncio.exceptions.CancelledError is asyn

Re: Python 3.9 asyncio: Task cancel() throws asyncio.exceptions.CancelledError instead of asyncio.CancelledError

2023-03-31 Thread Chris Angelico
python-3.9.7/lib/python3.9/site-packages/grpc/aio/_call.py", > line 406, in _consume_request_iterator > async for request in request_iterator: > File "/home/foo/lib/python/rush/client.py", line 105, in send_status > status = await sendq.get() > File > "

Python 3.9 asyncio: Task cancel() throws asyncio.exceptions.CancelledError instead of asyncio.CancelledError

2023-03-31 Thread Clint Olsen
equest_iterator async for request in request_iterator: File "/home/foo/lib/python/rush/client.py", line 105, in send_status status = await sendq.get() File "/home/utils/Python/3.9/3.9.7-20211101/lib/python3.9/asyncio/queues.py", line 166, in get await gette

Re: asyncio questions

2023-01-27 Thread Frank Millman
On 2023-01-27 2:14 PM, Frank Millman wrote: I have changed it to async, which I call with 'asyncio.run'. It now looks like this -     server = await asyncio.start_server(handle_client, host, port)     await setup_companies()     session_check = asyncio.create_task(     check_sessions(

Re: asyncio questions

2023-01-27 Thread Frank Millman
On 2023-01-26 7:16 PM, Dieter Maurer wrote: Frank Millman wrote at 2023-1-26 12:12 +0200: I have written a simple HTTP server using asyncio. It works, but I don't always understand how it works, so I was pleased that Python 3.11 introduced some new high-level concepts that hide the gory de

Re: asyncio questions

2023-01-26 Thread Dieter Maurer
Frank Millman wrote at 2023-1-26 12:12 +0200: >I have written a simple HTTP server using asyncio. It works, but I don't >always understand how it works, so I was pleased that Python 3.11 >introduced some new high-level concepts that hide the gory details. I >want to refactor my

Re: asyncio questions

2023-01-26 Thread Grant Edwards
On 2023-01-26, Frank Millman wrote: > I have written a simple HTTP server using asyncio. It works, but I don't > always understand how it works, I thought that was the rule with asyncio. ;) -- https://mail.python.org/mailman/listinfo/python-list

asyncio questions

2023-01-26 Thread Frank Millman
Hi all I have written a simple HTTP server using asyncio. It works, but I don't always understand how it works, so I was pleased that Python 3.11 introduced some new high-level concepts that hide the gory details. I want to refactor my code to use these concepts, but I am not finding it

Re: asyncio and tkinter (was: What should go to stdout/stderr and why Python logging write everything to stderr?)

2023-01-05 Thread Thomas Passin
On 1/5/2023 7:52 PM, Stefan Ram wrote: Thomas Passin writes: On 1/5/2023 4:24 PM, Stefan Ram wrote: You often can replace threads in tkinter by coroutines using asyncio when you write a replacement for the mainloop of tkinter that uses asyncio. Now, try to read only the official documentation

Pythonic way to run the asyncio loop forever in python 3.10

2022-10-06 Thread David Jander
not even be a single coroutine involved. Someone else asked something similar here: https://stackoverflow.com/questions/65684730/what-is-the-pythonic-way-of-running-an-asyncio-event-loop-forever Unfortunately all proposed answers look like dirty hacks. In concrete, how do I do this nicel

Re: asyncio+tkinter

2022-03-31 Thread Skip Montanaro
> > > Given that both asyncio & tkinter are modules in the standard lib and > both > > have event loops, I would have expected to find some "best practice" > > solution to mixing the two. > > Agreed. For GTK, you can use a dedicated lo

Re: difficult start with asyncio async/await

2022-03-23 Thread lacsaP Patatetom
some redesigns around asyncio.gather gave me what I wanted. here is the code used : ```python import asyncio from random import randint from termcolor import colored from datetime import datetime urls = ('yellow', 'cyan', 'green', 'magenta') async def ge

difficult start with asyncio async/await

2022-03-23 Thread lacsaP Patatetom
hi, difficult start with asyncio async/await... I'm trying to make a mockup that queries a few sites and posts the results to a server, but the result is not what I expected. I was expecting to get the 4 "get" one after the other, followed by the "post" (eventually m

Re: asyncio+tkinter

2022-03-21 Thread Chris Angelico
On Tue, 22 Mar 2022 at 10:52, Skip Montanaro wrote: > > Given that both asyncio & tkinter are modules in the standard lib and both > have event loops, I would have expected to find some "best practice" > solution to mixing the two. I've not used asyncio, but might f

asyncio+tkinter

2022-03-21 Thread Skip Montanaro
Given that both asyncio & tkinter are modules in the standard lib and both have event loops, I would have expected to find some "best practice" solution to mixing the two. I've not used asyncio, but might find it useful with the pynput module in the context of a Tk app. I see

asyncio: Gather over growing list of tasks

2021-01-27 Thread Justin Paston-Cooper
Hello, Let's say I have a loop where at each iteration, a task which makes an HTTP request to some endpoint is generated, and then the loop sleeps for n seconds. These tasks may throw exceptions. I can call asyncio.gather on these tasks once the loop has finished, but I actually want to stop the

Asyncio project code review

2021-01-08 Thread James
Good day for everyone. I have new asyncio project which use aiohttp connector and asyncio protocols/transports for tunneling packets through Tor Network cleanly. Project called aiotor: https://github.com/torpyorg/aiotor If someone with experience in asyncio field can make code review I will

asyncio project code review

2021-01-08 Thread James
Good day everyone. I have new asyncio project which use aiohttp connector and asyncio protocols/transports for tunneling packets through Tor Network cleanly. Project called aiotor: https://github.com/torpyorg/aiotor If someone with experience in asyncio field can make code review I will be

asyncio cancellation pattern

2020-12-28 Thread Joseph L. Casale
I've started writing some asyncio code in lieu of using threads and managing concurrency and primitives manually. Having spent a lot of time using c#'s async implementation, I am struggling to see an elegant pattern for implementing cancellation. With the necessity for the loop (that

Re: asyncio question

2020-11-03 Thread Kyle Stanley
you can either (a) use `loop.add_signal_handler()` or (b) make a slightly modified local version of `asyncio.run()` that has your desired KeyboardInterrupt behavior, based roughly on https://github.com/python/cpython/blob/master/Lib/asyncio/runners.py. However, using `loop.run_until_complete()` i

asyncio question

2020-11-03 Thread Frank Millman
Hi all My app runs an HTTP server using asyncio. A lot of the code dates back to Python 3.4, and I am trying to bring it up to date. There is one aspect I do not understand. The 'old' way looks like this - import asyncio def main(): loop = asyncio.get_

Re: Asyncio Queue implementation suggestion

2020-09-18 Thread Barry Scott
> On 17 Sep 2020, at 15:51, Dennis Lee Bieber wrote: > > On Wed, 16 Sep 2020 13:39:51 -0400, Alberto Sentieri <2...@tripolho.com> > declaimed the following: > > >> devices tested simultaneously, I soon run out of file descriptor. Well, >> I increased the number of file descriptor in the appl

Re: Asyncio Queue implementation suggestion

2020-09-17 Thread Léo El Amri via Python-list
ngth supports. By the way, Alberto, you can change the selector used by your event loop by instantiating the loop class by yourself [1]. You may want to use selectors.PollSelector [2]. [1] https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.SelectorEventLoop [2] https://docs.python.org/3/library/selectors.html#selectors.PollSelector - Léo -- https://mail.python.org/mailman/listinfo/python-list

Re: Asyncio Queue implementation suggestion

2020-09-17 Thread Léo El Amri via Python-list
Hello Alberto, I scrambled your original message a bit here. > Apparently asyncio Queues use a Linux pipe and each queue require 2 file > descriptors. Am I correct? As far as I know (And I know a bit about asyncio in CPython 3.5+) asyncio.queues.Queue doesn't use any file descri

Asyncio Queue implementation suggestion

2020-09-16 Thread Alberto Sentieri
I have a suggestion about the implementation of asyncio queues that could improve performance. I might be missing something, however. I am sort of new to Python. Below a short description of the problem I am facing. I wrote a daemon in Python 3 (running in Linux) which test many devices at

Re: Support both asyncio and synchronous callers

2020-07-28 Thread Barry Scott
> On 26 Jul 2020, at 02:36, Damian Johnson wrote: > > Hi. I'm the author of Stem, Tor's python library [1]. Recently we > migrated to asyncio, but desire to still be usable by synchronous > callers. > > We wrote a mixin [2][3] that transparently makes any cla

Support both asyncio and synchronous callers

2020-07-26 Thread Damian Johnson
Hi. I'm the author of Stem, Tor's python library [1]. Recently we migrated to asyncio, but desire to still be usable by synchronous callers. We wrote a mixin [2][3] that transparently makes any class usable by both asyncio and synchrono

Re: [Python-ideas] asyncio: return from multiple coroutines

2020-06-25 Thread Kyle Stanley
s likely going to be the best approach. I think you had the right general idea with your example, but here's a way to make it significantly less cumbersome and easy to expand upon (such as expanding the number of websockets to listen to): ``` import asyncio class MessengerQueue: def __init__

Re: [Python-ideas] asyncio: return from multiple coroutines

2020-06-23 Thread Pablo Alcain
or details on the functionality of > asyncio.wait(), see > https://docs.python.org/3/library/asyncio-task.html#asyncio.wait. > > I understand that I can create two coroutines that call the same > function, but it would be much cleaner (because of implementation issues) > if I can

Re: Intermittent bug with asyncio and MS Edge

2020-03-25 Thread Barry Scott
> On 25 Mar 2020, at 06:12, Frank Millman wrote: > > On 2020-03-24 8:39 PM, Barry Scott wrote: >>> On 24 Mar 2020, at 11:54, Frank Millman wrote: >>> >>> >>> I decided to concentrate on using Wireshark to detect the difference >>> between a Python3.7 session and a Python3.8 session. Alread

Re: Intermittent bug with asyncio and MS Edge

2020-03-24 Thread Chris Angelico
On Wed, Mar 25, 2020 at 5:14 PM Frank Millman wrote: > My guess is that 3.7 is slower to send the files, so Edge starts up all > 20 connections before it has finished receiving the first one, whereas > with 3.8, by the time it has opened a few connections the first file has > been received, so it

Re: Intermittent bug with asyncio and MS Edge

2020-03-24 Thread Frank Millman
On 2020-03-24 8:39 PM, Barry Scott wrote: On 24 Mar 2020, at 11:54, Frank Millman wrote: I decided to concentrate on using Wireshark to detect the difference between a Python3.7 session and a Python3.8 session. Already I can see some differences. There is only one version of my program. I

Re: Intermittent bug with asyncio and MS Edge

2020-03-24 Thread Barry Scott
> On 24 Mar 2020, at 11:54, Frank Millman wrote: > > On 2020-03-23 1:56 PM, Frank Millman wrote: >> On 2020-03-23 12:57 PM, Chris Angelico wrote: >>> On Mon, Mar 23, 2020 at 8:03 PM Frank Millman wrote: On 2020-03-22 12:11 PM, Chris Angelico wrote: > On Sun, Mar 22, 2020 at 8:3

Re: Intermittent bug with asyncio and MS Edge

2020-03-24 Thread Frank Millman
On 2020-03-24 1:54 PM, Frank Millman wrote: On 2020-03-23 1:56 PM, Frank Millman wrote: I have one frustration with Wireshark. I will mention it in case anyone has a solution. I can see that Edge opens multiple connections. I am trying to track the activity on each connection separately. I c

Re: Intermittent bug with asyncio and MS Edge

2020-03-24 Thread Frank Millman
On 2020-03-23 1:56 PM, Frank Millman wrote: On 2020-03-23 12:57 PM, Chris Angelico wrote: On Mon, Mar 23, 2020 at 8:03 PM Frank Millman wrote: On 2020-03-22 12:11 PM, Chris Angelico wrote: On Sun, Mar 22, 2020 at 8:30 PM Frank Millman wrote: On 2020-03-22 10:45 AM, Chris Angelico wrote:

Re: Intermittent bug with asyncio and MS Edge

2020-03-23 Thread Chris Angelico
On Mon, Mar 23, 2020 at 10:58 PM Frank Millman wrote: > > On 2020-03-23 12:57 PM, Chris Angelico wrote: > > On Mon, Mar 23, 2020 at 8:03 PM Frank Millman wrote: > >> > >> On 2020-03-22 12:11 PM, Chris Angelico wrote: > >>> On Sun, Mar 22, 2020 at 8:30 PM Frank Millman wrote: > > On 202

Re: Intermittent bug with asyncio and MS Edge

2020-03-23 Thread Barry Scott
> On 23 Mar 2020, at 09:02, Frank Millman wrote: > > On 2020-03-22 12:11 PM, Chris Angelico wrote: >> On Sun, Mar 22, 2020 at 8:30 PM Frank Millman wrote: >>> >>> On 2020-03-22 10:45 AM, Chris Angelico wrote: >> If you can recreate the problem with a single socket and multiple >> requests, t

Re: Intermittent bug with asyncio and MS Edge

2020-03-23 Thread Frank Millman
On 2020-03-23 12:57 PM, Chris Angelico wrote: On Mon, Mar 23, 2020 at 8:03 PM Frank Millman wrote: On 2020-03-22 12:11 PM, Chris Angelico wrote: On Sun, Mar 22, 2020 at 8:30 PM Frank Millman wrote: On 2020-03-22 10:45 AM, Chris Angelico wrote: If you can recreate the problem with a singl

Re: Intermittent bug with asyncio and MS Edge

2020-03-23 Thread Chris Angelico
On Mon, Mar 23, 2020 at 8:03 PM Frank Millman wrote: > > On 2020-03-22 12:11 PM, Chris Angelico wrote: > > On Sun, Mar 22, 2020 at 8:30 PM Frank Millman wrote: > >> > >> On 2020-03-22 10:45 AM, Chris Angelico wrote: > > > > If you can recreate the problem with a single socket and multiple > > req

Re: Intermittent bug with asyncio and MS Edge

2020-03-23 Thread Frank Millman
On 2020-03-22 12:11 PM, Chris Angelico wrote: On Sun, Mar 22, 2020 at 8:30 PM Frank Millman wrote: On 2020-03-22 10:45 AM, Chris Angelico wrote: If you can recreate the problem with a single socket and multiple requests, that would be extremely helpful. I also think it's highly likely that t

Re: Intermittent bug with asyncio and MS Edge

2020-03-22 Thread Barry Scott
rain() > Wait until it is appropriate to resume writing to the stream. Example: > > writer.write(data) > await writer.drain() > This is a flow control method that interacts with the underlying IO write > buffer. When the size of the buffer reaches the high watermark, dr

Re: Intermittent bug with asyncio and MS Edge

2020-03-22 Thread Barry Scott
> On 22 Mar 2020, at 11:59, Frank Millman wrote: > > On 2020-03-22 1:01 PM, Chris Angelico wrote: >> On Sun, Mar 22, 2020 at 12:45 AM Frank Millman wrote: >>> >>> Hi all >>> >>> I have a strange intermittent bug. >>> >>>

Re: Intermittent bug with asyncio and MS Edge

2020-03-22 Thread Frank Millman
On 2020-03-22 1:01 PM, Chris Angelico wrote: On Sun, Mar 22, 2020 at 12:45 AM Frank Millman wrote: Hi all I have a strange intermittent bug. The role-players - asyncio on Python 3.8 running on Windows 10 Microsoft Edge running as a browser on the same machine The bug does not

Re: Intermittent bug with asyncio and MS Edge

2020-03-22 Thread Kouli
aiting for another HTTP request). Kouli On Sun, Mar 22, 2020 at 12:04 PM Chris Angelico wrote: > On Sun, Mar 22, 2020 at 12:45 AM Frank Millman wrote: > > > > Hi all > > > > I have a strange intermittent bug. > > > > The role-players - >

Re: Intermittent bug with asyncio and MS Edge

2020-03-22 Thread Chris Angelico
On Sun, Mar 22, 2020 at 12:45 AM Frank Millman wrote: > > Hi all > > I have a strange intermittent bug. > > The role-players - > asyncio on Python 3.8 running on Windows 10 > Microsoft Edge running as a browser on the same machine > > The bug does not oc

Re: Intermittent bug with asyncio and MS Edge

2020-03-22 Thread Chris Angelico
y data and acknowledgement packet, and then whichever closing sequence gets used. > >> I have another data point. I tried putting an asyncio.sleep() after > >> sending each file. A value of 0.01 made no difference, but a value of 0.1 > >> makes the problem go away. >

Re: Intermittent bug with asyncio and MS Edge

2020-03-22 Thread Chris Angelico
On Sun, Mar 22, 2020 at 8:30 PM Frank Millman wrote: > > On 2020-03-22 10:45 AM, Chris Angelico wrote: > > On Sun, Mar 22, 2020 at 6:58 PM Frank Millman wrote: > >>> I'd look at the network traffic with wireshark to see if there is > >>> anything different between edge and the other browsers. >

Re: Intermittent bug with asyncio and MS Edge

2020-03-22 Thread Frank Millman
On 2020-03-22 11:00 AM, Barry Scott wrote: On 22 Mar 2020, at 07:56, Frank Millman wrote: On 2020-03-21 8:04 PM, Barry Scott wrote: I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers. You are leading me into deep water

Re: Intermittent bug with asyncio and MS Edge

2020-03-22 Thread Frank Millman
On 2020-03-22 10:45 AM, Chris Angelico wrote: On Sun, Mar 22, 2020 at 6:58 PM Frank Millman wrote: I'd look at the network traffic with wireshark to see if there is anything different between edge and the other browsers. You are leading me into deep waters here :-) I have never used Wiresh

Re: Intermittent bug with asyncio and MS Edge

2020-03-22 Thread Barry Scott
> On 22 Mar 2020, at 07:56, Frank Millman wrote: > > On 2020-03-21 8:04 PM, Barry Scott wrote: >>> On 21 Mar 2020, at 13:43, Frank Millman wrote: >>> >>> Hi all >>> >>> I have a strange intermittent bug. >>> >>&g

Re: Intermittent bug with asyncio and MS Edge

2020-03-22 Thread Chris Angelico
On Sun, Mar 22, 2020 at 6:58 PM Frank Millman wrote: > > I'd look at the network traffic with wireshark to see if there is anything > > different between edge and the other browsers. > > > > You are leading me into deep waters here :-) I have never used > Wireshark before. I have now downloaded

Re: Intermittent bug with asyncio and MS Edge

2020-03-22 Thread Frank Millman
On 2020-03-21 8:04 PM, Barry Scott wrote: On 21 Mar 2020, at 13:43, Frank Millman wrote: Hi all I have a strange intermittent bug. The role-players - asyncio on Python 3.8 running on Windows 10 Microsoft Edge running as a browser on the same machine The bug does not occur with

Re: Intermittent bug with asyncio and MS Edge

2020-03-21 Thread Barry Scott
> On 21 Mar 2020, at 13:43, Frank Millman wrote: > > Hi all > > I have a strange intermittent bug. > > The role-players - >asyncio on Python 3.8 running on Windows 10 >Microsoft Edge running as a browser on the same machine > > The bug does not occ

Intermittent bug with asyncio and MS Edge

2020-03-21 Thread Frank Millman
Hi all I have a strange intermittent bug. The role-players - asyncio on Python 3.8 running on Windows 10 Microsoft Edge running as a browser on the same machine The bug does not occur with Python 3.7. It does not occur with Chrome or Firefox. It does not occur when MS Edge connects to

Re: Asyncio question (rmlibre)

2020-02-28 Thread Frank Millman
On 2020-02-28 1:37 AM, rmli...@riseup.net wrote: > What resources are you trying to conserve? > > If you want to try conserving time, you shouldn't have to worry about > starting too many background tasks. That's because asyncio code was > designed to be extremely t

Re: Asyncio question (rmlibre)

2020-02-27 Thread rmlibre
What resources are you trying to conserve? If you want to try conserving time, you shouldn't have to worry about starting too many background tasks. That's because asyncio code was designed to be extremely time efficient at handling large numbers of concurrent async tasks.

Re: Asyncio question

2020-02-21 Thread Frank Millman
ks active at the same time. The whole point of asyncio is to make tasks very lightweight, so you can use as many of them as is convenient without worries. One task per client sounds like the right thing to do here. Perfect. Thanks so much. Frank -- https://mail.python.org/mailman/listinfo/python-list

Re: Asyncio question

2020-02-21 Thread Greg Ewing
e point of asyncio is to make tasks very lightweight, so you can use as many of them as is convenient without worries. One task per client sounds like the right thing to do here. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Asyncio question

2020-02-20 Thread Frank Millman
Hi all I use asyncio in my project, and it works very well without my having to understand what goes on under the hood. It is a multi-user client/server system, and I want it to scale to many concurrent users. I have a situation where I have to decide between two approaches, and I want to

asyncio event guarantees to notify all waiting?

2019-11-01 Thread Toon Knapen
Hello, I'm wondering if set'ing an asyncio.Event guarantees to notify all tasks that are waiting for the event ? Thus even if I `set()` the event and directly `clear()` the event, considering that both thus instructions are no co-routines and thus will not return control to the event-loop, wil

Handling of disconnecting clients in asyncio

2019-09-24 Thread Johannes Bauer
Hi group, I'm trying to get into async programming using Python. Concretely I open a UNIX socket server in my application. The UNIX socket server generates events and also receives commands/responds to them. I do this by: async def _create_local_server(self): await asyncio.start_unix_server(

asyncio, transports, protocols, etc.

2019-08-05 Thread Hugh Sasse
Hello, I didn't get a response to this before, possibly because of lack of concision. I'd like to ask whether (provided I'm understanding this): https://docs.python.org/3/library/asyncio-protocol.html#tcp-echo-server could be improved by adding: """ Crea

asyncio, transports, protocols, etc.

2019-07-22 Thread Hugh Sasse
Hello, I'm trying to get my head around asyncio, and I think I'm mostly there now, (but expect to be proved wrong :-)!). It appears to be about the newest of the PEPs according to my searches, including PEP 0, so I don't expect a huge amount of supporting documentatio

Re: The state of asyncio in 2019

2019-05-19 Thread Chris Angelico
On Mon, May 20, 2019 at 11:56 AM Becaree wrote: > > So i started to use asyncio some times ago. I see a lots of threads/forums > which date back from 2015 or older. My question is what the state of asyncio > in 2019? I guess, the major constrain of having async/await is quiet a &

The state of asyncio in 2019

2019-05-19 Thread Becaree
So i started to use asyncio some times ago. I see a lots of threads/forums which date back from 2015 or older. My question is what the state of asyncio in 2019? I guess, the major constrain of having async/await is quiet a drawback. I do love asyncio but reinventing the wheel using it is

Re: asyncio based xdserver (libdurus 4.1)

2019-04-13 Thread Soppy bear
References: 1. https://bitbucket.org/tkadm30/libschevo/src/4.0-devel/lib/schevo/xdserver/server.py 2. https://bitbucket.org/tkadm30/libschevo/src/4.0-devel/tools/schevo-daemonize Sorry i might have talked too fast... lol :) i am still not sure yet how python 3 internally use asyncio with

asyncio based xdserver (libdurus 4.1)

2019-04-13 Thread Soppy bear
Good morning Python world, Our high performance asyncio based xdserver (Durus 4.1 socket server on top of schevo 4.1 api) is now fully working with Python 3.7 on linux debian :) cheers!! soppy bear download: https://pypi.org/project/libdurus/ https://pypi.org/project/libschevo/ demo: https

asyncio KeyboardInterrupt in select

2019-03-27 Thread Thomas Grainger
It seems quite easy to cause asyncio to deadlock: File "/usr/lib/python3.6/asyncio/base_events.py", line 1404, in _run_once event_list = self._selector.select(timeout) File "/usr/lib/python3.6/selectors.py", line 445, in select fd_event_list = self._epoll.

RE: asyncio Question

2019-03-15 Thread Joseph L. Casale
> -Original Message- > From: Python-list bounces+jcasale=activenetwerx@python.org> On Behalf Of Simon > Connah > Sent: Thursday, March 14, 2019 3:03 AM > To: Python > Subject: asyncio Question > > Hi, > > Hopefully this isn't a stupid ques

asyncio Question

2019-03-14 Thread Simon Connah
Hi, Hopefully this isn't a stupid question. For the record I am using Python 3.7 on Ubuntu Linux. I've decided to use asyncio to write a TCP network server using Streams and asyncio.start_server(). I can handle that part of it without many problems as the documentation is pret

[asyncio] Suggestion for a major PEP

2018-12-16 Thread Christophe Bailly
Hello, I copy paste the main idea from an article I have written: contextual async " Imagine you have some code written for monothread. And you want to include your code in a multithread environment. Do you need to adapt all your c

Re: Asyncio tasks getting cancelled

2018-11-21 Thread ike
sks weren't started at all. > > Ah. I don't think asyncio uses a RUNNING state. There's nothing about > it in the docs; tasks are either done or they're not: > https://docs.python.org/3/library/asyncio-task.html#task-object > > And inspecting the current

Re: Asyncio tasks getting cancelled

2018-11-06 Thread Ian Kelly
it appears the tasks weren't started at all. > > Ah. I don't think asyncio uses a RUNNING state. There's nothing about > it in the docs; tasks are either done or they're not: > https://docs.python.org/3/library/asyncio-task.html#task-object > > And inspecting the c

Re: Asyncio tasks getting cancelled

2018-11-06 Thread Ian Kelly
n Mon, Nov 5, 2018 at 8:43 PM wrote: > > On Mon, Nov 05, 2018 at 07:15:04PM -0700, Ian Kelly wrote: > > > For context: > > > https://github.com/ldo/dbussy/issues/13 > > > https://gist.github.com/tu500/3232fe03bd1d85b1529c558f920b8e43 > > > > >

Re: Asyncio tasks getting cancelled

2018-11-05 Thread ike
On Mon, Nov 05, 2018 at 07:15:04PM -0700, Ian Kelly wrote: > > For context: > > https://github.com/ldo/dbussy/issues/13 > > https://gist.github.com/tu500/3232fe03bd1d85b1529c558f920b8e43 > > > > It really feels like asyncio is loosing strong references to sched

Re: Asyncio tasks getting cancelled

2018-11-05 Thread Ian Kelly
has completed in the first place. > For context: > https://github.com/ldo/dbussy/issues/13 > https://gist.github.com/tu500/3232fe03bd1d85b1529c558f920b8e43 > > It really feels like asyncio is loosing strong references to scheduled > tasks, as excplicitly keeping them around helps.

Re: Asyncio tasks getting cancelled

2018-11-05 Thread philip . m
salt, but it seems to me that anything that you want to resolve > before the event loop terminates should be awaited either directly or > indirectly by the main coroutine. From the documentation: > > """ > This function always creates a new event loop and closes it a

Re: Asyncio tasks getting cancelled

2018-11-05 Thread ike
On Tue, Nov 06, 2018 at 12:45:03AM +0100, i...@koeln.ccc.de wrote: > Also, I may be overlooking things, but I haven't found a way to add a > task before calling run_forever(), as asyncio will then say the loop > isn't running yet. So I'm not sure how you would jumpstart

Re: Asyncio tasks getting cancelled

2018-11-05 Thread ike
salt, but it seems to me that anything that you want to resolve > before the event loop terminates should be awaited either directly or > indirectly by the main coroutine. From the documentation: > > """ > This function always creates a new event loop and closes it a

Re: Asyncio tasks getting cancelled

2018-11-05 Thread Ian Kelly
From the documentation: """ This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. """ So I think part of the idea with this is that the asyncio.run m

Re: Asyncio tasks getting cancelled

2018-11-05 Thread Léo El Amri via Python-list
pointed out, using both asyncio.run() and loop.run_forever() is not what you are looking for. > Yet it still looks like asyncio > doen'st keep strong references. You may want to look at PEP 3156. It's the PEP defining asyncio. Ian made a good explanation about why your loop was

Re: Asyncio tasks getting cancelled

2018-11-05 Thread ike
This weird mixing was actually a side effect of me quickly coming up with a small example, sorry for the confusion. I just saw, actually using the same loop gets rid of the behavior in this case and now I'm not sure about my assertions any more. Yet it still looks like asyncio doen'st k

Re: Asyncio tasks getting cancelled

2018-11-05 Thread Léo El Amri via Python-list
On 05/11/2018 07:55, Ian Kelly wrote: >> I assume it's kind of a run_forever() with some code before it >> to schedule the coroutine. > > My understanding of asyncio.run() from > https://github.com/python/asyncio/pull/465 is that asyncio.run() is > m

  1   2   3   4   5   >