[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-11-18 Thread R. David Murray
R. David Murray added the comment: I think the 'versionchanged' should say "3.4.4, 3.5.1". We've already had one user confused by the fact that it isn't in 3.5.0. -- ___ Python tracker

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-11-18 Thread Yury Selivanov
Yury Selivanov added the comment: Good catch! Fixed in https://hg.python.org/cpython/rev/b34c42e46e7b -- ___ Python tracker ___

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-05 Thread Vincent Michel
Vincent Michel added the comment: I attached a patch that should sum up all the points we discussed. I replaced the `call_soon_threadsafe` example with: loop.call_soon_threadsafe(callback, *args) cause I couldn't find a simple specific usage. Let me know if you think of a better example.

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-05 Thread Guido van Rossum
Guido van Rossum added the comment: loop *is* required for this function. It's just that there's an earlier, general comment describing it as optional for all functions in this section. -- ___ Python tracker

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-05 Thread Vincent Michel
Vincent Michel added the comment: > The docs look good. Should I add a note to explain why the loop argument has to be explicitly passed? (there is a note at the beginning of the `task functions` section stating "In the functions below, the optional loop argument ...") > What do you need to

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-05 Thread Yury Selivanov
Yury Selivanov added the comment: >> Should I add a note to explain why the loop argument has to be explicitly passed? (there is a note at the beginning of the `task functions` section stating "In the functions below, the optional loop argument ...") > Oh, that's a good idea. It's sort of clear

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-05 Thread Vincent Michel
Vincent Michel added the comment: I attached the first version of the documentation for `run_coroutine_threadsafe`. The `Concurrency and multithreading` section also needs to be updated but I could already use some feedback. Also, I think we should add a `try-except` in the callback function,

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-05 Thread Guido van Rossum
Guido van Rossum added the comment: > Should I add a note to explain why the loop argument has to be explicitly passed? (there is a note at the beginning of the `task functions` section stating "In the functions below, the optional loop argument ...") Oh, that's a good idea. It's sort of clear

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-05 Thread Guido van Rossum
Guido van Rossum added the comment: The docs look good. (I assume you've generated the HTML and checked that the output looks good, links are clickable etc.) What do you need to add to the concurrency and multithreading section? I agree on the try/except; can you add that to the same diff?

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-04 Thread R. David Murray
R. David Murray added the comment: I thought you might be interested to know what the name suggests to a relative newcomer to asyncio. When I saw this issue opened, I though "oh, good, an easy way to submit a coroutine from a thread in my test code, now I don't have to write

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-04 Thread Vincent Michel
Vincent Michel added the comment: While I was working on the documentation update, I realized that what we called `run_coroutine_threadsafe` is actually a thread-safe version of `ensure_future`. What about renaming it to `ensure_future_threadsafe`? It might be a bit late since

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-04 Thread Guido van Rossum
Guido van Rossum added the comment: I'm against that idea. I don't really see a great important future for this method either way: It's just a little bit of glue between the threaded and asyncio worlds, and people will learn how to use it by finding an example. The existing ensure_future()

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-04 Thread Yury Selivanov
Yury Selivanov added the comment: > - it is less confusing, because it has the same name and using the same > prototype as `ensure_future` > - it accepts futures and awaitables I like this idea. -- ___ Python tracker

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-04 Thread Yury Selivanov
Yury Selivanov added the comment: > But honestly I *don't* want to encourage flipping back and forth between > threads and event loops; I see it as a necessary evil. The name we currently > have is fine from the POV of someone coding in the threaded world who wants > to hand off something to

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-04 Thread Guido van Rossum
Guido van Rossum added the comment: @rdm: thanks, you nailed it. :-) @yury: but where would you have gotten the awaitable in the first place? It's easy to see how to get a coroutine -- just define it (with either @coroutine or async def) and call it -- and I think that's the only use case

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-04 Thread Yury Selivanov
Yury Selivanov added the comment: > @yury: but where would you have gotten the awaitable in the first place? It's > easy to see how to get a coroutine -- just define it (with either @coroutine > or async def) and call it -- and I think that's the only use case that > matters here. Just a few

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-04 Thread Guido van Rossum
Guido van Rossum added the comment: Well, I still worry that this is just going to encourage more people to try and call awaitables from threaded code, and through some circuitous path of misunderstandings (probably involving StackOverflow :-) end up using this function. (Pretty much the

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-03 Thread Guido van Rossum
Changes by Guido van Rossum : -- nosy: +vxgmichel ___ Python tracker ___ ___

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-03 Thread Guido van Rossum
Changes by Guido van Rossum : -- stage: -> commit review type: -> behavior ___ Python tracker ___

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-03 Thread Guido van Rossum
Guido van Rossum added the comment: It's done. But I am hoping you (or someone) will add docs. -- ___ Python tracker ___

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset 25e05b3e1869 by Guido van Rossum in branch '3.4': Issue #25304: Add asyncio.run_coroutine_threadsafe(). By Vincent Michel. https://hg.python.org/cpython/rev/25e05b3e1869 New changeset e0db10d8c95e by Guido van Rossum in branch '3.5': Issue #25304:

[issue25304] Add run_coroutine_threadsafe() to asyncio

2015-10-03 Thread Guido van Rossum
New submission from Guido van Rossum: This is a placeholder bug to reference the PR: https://github.com/python/asyncio/pull/273 by Vincent Michel. -- assignee: gvanrossum components: asyncio messages: 252215 nosy: gvanrossum, haypo, yselivanov priority: normal severity: normal status: