Open brizzbane opened 8 years ago
What is cURLHTTPRequest
? I assume this is an external library? Unless that is specifically written or configured to work with Gruvi it is not going to work. It would need to use Gruvi and pyuv to implement cooperative IO.
Your options are to either run this external library use blocking IO and run it in a thread pool (gruvi.get_io_pool()
), or use gruvi.http.HttpRequest
. A third option that sometimes works is if cURLHTTPRequest
supports asynchronous IO callbacks is to use those to call into Gruvi for async IO (typically using get_hub().poll
.
If you read my reply (previous, deleted)--trying to condense and clarify.
It's a custom pycurl client I made..specifically trying to integrate with gruvi and pyuv, because I love eventloops.
client.req() returns a future. the request WORKS as in its processed, but when I try to 'read' the result, gruvi complains that I can not view .result() from the main hub.
So, yes, its specifically for gruvi. My question I guess is how can I read the future's result? Does it need to be 'inside' a switchback, or..?
I think I may just be confused, heh. Right now, my issue when putting a request into a Fiber, and get_hub().switch(), is that if Im trying to do multiple requests, it just stops after the first (i.e. loop is still running, but doesn't go on to next request).
ugh. Im going to mess around w/things for a few more days so I don't waste your time. I kind of didn't look at the Poller docs before.
OK.
https://gist.github.com/brizzbane/b799ef86fa73ea119308
@ the bottom main. Only the first item in the list proceeds. Am I misunderstanding something fundamental?
if __name__ == '__main__':
ioloop = gruvi.get_hub().loop
c = cURLSMTPClient(ioloop)
users = ['henry', 'tom', 'terrry', 'joejoe', 'ashley', 'sara', 'jessi']
for u in users:
r = cURLSMTPRequest(url='smtp://mail.mailinator.com/',
mail_from='timmyjones1@gmail.com',
mail_rcpt='%s@bobmail.info' % u,
message='hi')
future = gruvi.Fiber(c.req, (r,))
future.start()
gruvi.get_hub().switch()
I'm wanting to use pycurl + pyuv, because I also believe it to be best available implementation of an eventloop. Your library and rationale really strike a cord w/me, so wanting to understand how to work w/it properly (and read the result of futures).
If you have the time to help, would be much appreciated. If you find value w/any of the pycurl + implementation I have, feel free to grab it and publish. There is still a lot of code in above gist from different ways I've tried implementing handling file descriptor events.
Hi @brizzbane ,
not sure if you are still interested in this given that you reported this a long time ago. Recently I have gotten some free time again to work on Gruvi.
If you're still trying to get this to work, please share a preferably small and standalone reproducer. Happy to have a look.
Love what you made. I've been wanting to figure this out for a while, but have been hesitant to ask.
Can you help me with this.., not sure if I'm understanding how to use get_hub().switch() correctly.
Here is an example of what I'm trying to accomplish..
So combining Fibers & (ultimately) results of the values of Futures. Didn't see any examples using gruvi.get_hub().switch() AND switchback.
MUCH appreciated.