[Python-Dev] Re: Starting a new thread

2022-05-13 Thread Guido van Rossum
Thinking about it, it's actually a fine design to have a decorator that turns a regular function into one that starts a thread -- from the caller's POV it's no different than having a function that explicitly starts a thread, and it could be a nice shorthand if you do this all the time. (You have

[Python-Dev] Re: Starting a new thread

2022-05-12 Thread Serhiy Storchaka
10.05.22 18:12, Barney Stratford пише: This has a couple of advantages. I don’t have to import the threading module all over my code. I can use the neater syntax of function calls. The function’s definition makes it clear it’s returning a new thread since it’s decorated. It gets the plumbing

[Python-Dev] Re: Starting a new thread

2022-05-12 Thread Cameron Simpson
On 12May2022 20:17, Barney Stratford wrote: >It seems like the consensus is that this is a good idea, but it’s the >wrong good idea. Should I cancel the PR or should we try to make it >into a better good idea? Why not shift slightly? As remarked, having a function automatically spawn threads

[Python-Dev] Re: Starting a new thread

2022-05-12 Thread Guido van Rossum
It’s definitely too early for a PR, so if you already have one (I didn’t see one linked to this thread) please close it. Then once we’ve bikeshedded the right good idea you can start a new PR. On Thu, May 12, 2022 at 12:21 Barney Stratford wrote: > It seems like the consensus is that this is a

[Python-Dev] Re: Starting a new thread

2022-05-12 Thread Barney Stratford
It seems like the consensus is that this is a good idea, but it’s the wrong good idea. Should I cancel the PR or should we try to make it into a better good idea? Cheers, Barney. ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send

[Python-Dev] Re: Starting a new thread

2022-05-12 Thread Antoine Pitrou
On Tue, 10 May 2022 16:12:13 +0100 Barney Stratford wrote: > Hello all. > > It occurs to me that creating threads in Python is more awkward than it needs > to be. Every time I want to start a new thread, I end up writing the same > thing over and over again: > > def target(*args, **kwds): >

[Python-Dev] Re: Starting a new thread

2022-05-10 Thread Gregory P. Smith
On Tue, May 10, 2022 at 10:34 AM Barney Stratford < barney_stratf...@fastmail.fm> wrote: > > 1. Does t = target(...) start the thread? I think it does. > I think it does too. In the commonest use case, immediately after creating > a thread, you start it. And if you want to delay the thread but

[Python-Dev] Re: Starting a new thread

2022-05-10 Thread Barney Stratford
> 1. Does t = target(...) start the thread? I think it does. I think it does too. In the commonest use case, immediately after creating a thread, you start it. And if you want to delay the thread but still use the decorator, then you can do that explicitly with some locks. In fact, it’s

[Python-Dev] Re: Starting a new thread

2022-05-10 Thread Joao S. O. Bueno
On Tue, May 10, 2022 at 1:20 PM Paul Moore wrote: > On Tue, 10 May 2022 at 16:31, Barney Stratford > wrote: > > > > Hello all. > > > > It occurs to me that creating threads in Python is more awkward than it > needs to be. Every time I want to start a new thread, I end up writing the > same

[Python-Dev] Re: Starting a new thread

2022-05-10 Thread Paul Moore
On Tue, 10 May 2022 at 16:31, Barney Stratford wrote: > > Hello all. > > It occurs to me that creating threads in Python is more awkward than it needs > to be. Every time I want to start a new thread, I end up writing the same > thing over and over again: > > def target(*args, **kwds): >