Closed LivInTheLookingGlass closed 7 years ago
If you'd like, @syrusakbary, I could revise this to only include the test for #9 and the initial 4 line commit. I would understand if this is a bit large to review.
@syrusakbary, I would very much appreciate a response. I would like to use this as a dependency in my project, but I need this patch to be released before I can do anything. I cannot release my code until I have some sort of answer.
Hi @gappleto97, sorry for taking long in reviewing... I've been super occupied lately.
I really like the direction of this PR as it focus on fixing #9, however I'm worried about the implications of starting a Thread
for each resolved promise.
In a "synchronous" python environment starting a thread might be the path to go, however in environments where gevent
or asyncio
(event loops) are used, starting a Thread
is not really necessary and introduces a significant overhead.
I would love to see if we can find a way to make both strategies to work :)
I get where you're coming from.
There are two reasons I didn't go that route. First, because I'm mainly looking for compatibility. But more importantly, I'm just not as familiar with that side of things yet.
If you can suggest some things to investigate, I'm more than happy to do so. It may take some time to reach that level though. I would prefer if we merged the current code, with the understanding that the next version will have something more performant.
And like I said, I'm more than happy to contribute upstream.
After thinking a while, I think the best strategy is create different loop strategies in this package.
I will work in a branch based on your work in this PR :)
Okay. Feel free to pull me in if you'd like the help.
This is merged, but excluding the thread creation per promise (I liked your code & syntax improvements).
I'm working on an optimal schedulers approach.
Sweet, thanks! Please let me know when that is finished, or how I can help.
Shouldn't we still have the "start new thread" behavior, so that systems without asyncio can still function correctly? I admit I don't know, but wouldn't that close off 2.7 support for good?
Yeah, some cases (like in Python 2.7) Threads
might still be necessary.
In this case, there will be an automatic get_default_scheduler
that will return the best scheduler for the environment:
Thread
(+ThreadPoolExecutor
?) schedulerAsyncIO
scheduler (using the event loop)sync
schedulerAlso, there will be a setter set_default_scheduler
, that will permit developer to use custom ones (probably also provided by this library):
Gevent
schedulerTornado
schedulerOkay. That'd be cool.
In the interest of being able to release, I think I'm going to stick with my fork until this is merged. However, I think what you're doing is way better, and if there's any way to help, please let me know.
Will do! Thanks!!
If you have any idea of how to optimize the current code, or any other suggestions about scheduling/async please let me know.
I'm researching a lot into different promises implementations:
In general, most of them use a Queue
+ async function invocation.
The async invocations are mainly triggered on the then
method in a instantiated Promise
, instead of the resolution per se.
I'll do what I can to work on the current codebase. I'm not very familiar with Python's event loop setup, and I'm pretty sure I'd only slow you down on that front.
I'll definitely make sure to look into it once the design framework is put in place though.
This patch also makes some other minor changes:
float("Inf")
, rather thanNone
, so that it still listens toKeyboardInterrupt
"".format()
From my testing, this should also fix #9