Fixes #7052 gevent/eventlet 1 seconds latency #7089
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #7052
When there are used asynchronous backend as Redis with pubsub, result of short task (0.1s length, for example) available immediate.
When execute AsyncResult.get() under gevent/eventlet environment, result of the same short (0.1s) tasks became available after 1s, it is too slowely.
Current behavior is result of GH-5974 that prevent event loop blocking by very offen checking task results and very short wait_for length.
Current implementation of greenletDrainer cause wait_for to only return every "timeout" # of seconds, rather than returning immediately.
Solutuion:
I add new internal event
_drain_complete_event
that rising every time after socket operation result_consumer.drain_events (for example _pubsub.get_message for Redis backend) occurs.Every
wait_for
are waiting for this particular event, so it won't cause overhead, because socket operation still not block event loop and let other greenlets executing normaly.