Ascync non-blocking?
See original GitHub issueIs it possible to initialize a pool to return the result but continue the code execution like so?
import grequests
def print_res(res, *args, **kwargs):
from pprint import pprint
pprint (vars(res))
print 'starting grequest'
req = grequests.post('http://www.cricket.com.au/', hooks=dict(response=print_res))
job = grequests.send(req, grequests.Pool(1))
print 'request made'
for i in range(10):
print i
So that would show the request was made but still print the range while the request was in process and then finally print out the results of the send?
I’d really love to use grequests but the examples/documentation are fairly sparse so I’m struggling.
Thanks for any help.
Issue Analytics
- State:
- Created 8 years ago
- Comments:8
Top Results From Across the Web
asynchronous and non-blocking calls? also between ...
Asynchronous program: A program which uses Non blocking calls. It can have only 1 thread and still remain interactive. Share.
Read more >The difference between asynchronous and non-blocking
Asynchronous and non-blocking I/O are the opposites of synchronous and blocking. In a sense both are fairly similar in that they allow your...
Read more >Overview of Blocking vs Non-Blocking
Choosing non-blocking asynchronous operations frees up that 45ms per request to handle other requests. This is a significant difference in capacity just by ......
Read more >How Java Is Used for Asynchronous Non-blocking ...
In this article, the author explains several methods used for asynchronous non-blocking programming in Java.
Read more >Blocking and Non-Blocking in Node.js
Non -Blocking: It refers to the program that does not block the execution of further operations. Non-Blocking methods are executed asynchronously ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jakehilton
Hey Jake,
This library is blocking calling thread, so it’s not as asynchronous as you could think. It’s like half-asynchronous, dunno how to call that… I think lots of people actually think it’ll send the HTTP task to separate thread-pool and eventually call back with results, but it doesn’t. Yes, it sends multiple requests, which are asynchronous TO EACH OTHER, and awaits them (https://github.com/kennethreitz/grequests/blob/master/grequests.py#L117). And that is really confusing. I think authors should clarify that in docs.
From the readme: Note: You should probably use requests-threads or requests-futures instead.