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
On 2024-03-22 12:08 PM, Thomas Nyberg via Python-list 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 sam

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 asyncio i

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 use them across diff

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

2024-03-22 Thread Frank Millman via Python-list
On 2024-03-22 1:23 PM, Frank Millman via Python-list wrote: On 2024-03-22 12:09 PM, Frank Millman via Python-list wrote: I am no expert. However, I do have something similar in my app, and it works. I do not use 'await future', I use 'asyncio.wait_for(future)'. I tested it and it did not

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

2024-03-22 Thread Frank Millman via Python-list
On 2024-03-22 12:09 PM, Frank Millman via Python-list wrote: I am no expert. However, I do have something similar in my app, and it works. I do not use 'await future', I use 'asyncio.wait_for(future)'. I tested it and it did not work. I am not sure, but I think the problem is that you hav

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

2024-03-22 Thread Lars Liedtke via Python-list
Sorry, must have missed that :-/ Lars Liedtke Lead Developer [Tel.] +49 721 98993- [Fax] +49 721 98993- [E-Mail]l...@solute.de solute GmbH Zeppelinstraße 15 76185 Karlsruhe Germany [Marken] Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaate

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

2024-03-22 Thread Frank Millman via Python-list
On 2024-03-20 10:22 AM, Thomas Nyberg via Python-list wrote: 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` ``` imp

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 threading import

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 with asyncio" but I don't k

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 [Tel.] +49 721 9

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 queue import Qu

Re: How come I can't get get my background thread to output anything?

2009-04-09 Thread Carl Banks
On Apr 9, 8:36 pm, grocery_stocker wrote: > On Apr 9, 7:01 pm, grocery_stocker wrote: > > > > > On Apr 9, 6:36 pm, grocery_stocker wrote: > > > > Given the following > > > > #!/usr/local/bin/python > > > > import os > > > import time > > > import thread > > > > def domsg(string, sleeptime, *

Re: How come I can't get get my background thread to output anything?

2009-04-09 Thread grocery_stocker
On Apr 9, 7:01 pm, grocery_stocker wrote: > On Apr 9, 6:36 pm, grocery_stocker wrote: > > > Given the following > > > #!/usr/local/bin/python > > > import os > > import time > > import thread > > > def domsg(string, sleeptime, *args): > > print "%s was here", string > > #os.system('te

Re: How come I can't get get my background thread to output anything?

2009-04-09 Thread grocery_stocker
On Apr 9, 6:36 pm, grocery_stocker wrote: > Given the following > > #!/usr/local/bin/python > > import os > import time > import thread > > def domsg(string, sleeptime, *args): > print "%s was here", string > #os.system('tel %s test' % person); > #time.sleep(sleeptime) > > def buil

How come I get get my background thread to output anything?

2009-04-09 Thread grocery_stocker
Given the following #!/usr/local/bin/python import os import time import thread def domsg(string, sleeptime, *args): print "%s was here", string #os.system('tel %s test' % person); #time.sleep(sleeptime) def buildlist(): out = 1 persons = [] while(out != 0):

Tkinter: stopping a background thread on demand

2009-02-19 Thread coldpizza
I am writing a Tk GUI for a console script. I start a background thread and pass it a callback function which writes debug info to a Text widget in the main Tk loop. I tried to find what is the established way to cleanly abort a child thread when the user clicks the Stop button, but apparently

Background thread or non-blocking raw_input

2005-06-26 Thread Jorge Louis De Castro
Hi,   I've posted this before but the answer given made use of twisted functions that do not work on windows, so i'm forced to repost. Basically, is there a way to have a thread running on the background that over rules the raw_input function? The example I'm working on is something like hav

Re: Background thread

2005-06-25 Thread Jp Calderone
On Sat, 25 Jun 2005 11:36:57 +0100, Jorge Louis De Castro <[EMAIL PROTECTED]> wrote: >Hi, > >I'm new to python and I'm having trouble figuring out a way to have a thread >running on the background that over rules the raw_input function. The example >I'm working on is something like having a thre

Background thread

2005-06-25 Thread Jorge Louis De Castro
Hi,   I'm new to python and I'm having trouble figuring out a way to have a thread running on the background that over rules the raw_input function. The example I'm working on is something like having a thread that prints "You're taking too long" every 10 seconds, while waiting for input fro