-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add queue overflow handler in asyncsender. #156
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests to cover and see comments inline.
fluent/asyncsender.py
Outdated
@@ -132,5 +135,13 @@ def _send_loop(self): | |||
finally: | |||
self._close() | |||
|
|||
def _call_queue_overflow_handler(self, discarded_bytes): | |||
try: | |||
if self._queue_overflow_handler: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like checks like that in the critical paths, as it's going to be repeated every call.
Can we push it up into the constructor like we do here https://github.com/fluent/fluent-logger-python/blob/master/fluent/handler.py#L86?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't support Python 2 anymore, there is no need for these changes.
UPD: Nevermind, we still do. :)
I have just added improved test. |
I'm travelling and will try to get to this tonight. |
up |
fluent/asyncsender.py
Outdated
@@ -109,7 +114,8 @@ def _send(self, bytes_): | |||
if self._queue_circular and self._queue.full(): | |||
# discard oldest | |||
try: | |||
self._queue.get(block=False) | |||
discarded_bytes = self._queue.get(block=False) | |||
self._queue_overflow_handler(discarded_bytes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This particular line concerns me a bit. If self._queue_overflow_handler
raises an Empty
, it's going to go into pass
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just resolved it. I hope it does a job.
@pguz sorry, it was Pending review for two weeks now, because I always forget to actually submit the review :( |
Locally I am not receiving these errors. Is it testing environment issue? |
Nope, that's a dependency issue, i.e. your local testing environment issue :) |
Signed-off-by: Paweł Guz <pawel.guz@socialwifi.com>
Signed-off-by: Paweł Guz <pawel.guz@socialwifi.com>
Signed-off-by: Paweł Guz <pawel.guz@socialwifi.com>
Hi @arcivanov, this PR looks like a nice addition. Would you have any hints as to why one test fails only o Python 2.7 on Travis? What can be done to move this forward?
|
Signed-off-by: pguz <pawelguz@gmail.com>
Hi, I fixed this issue writing more
We can see that in newer series of tests for python 2.7 tests are passing and even the condition which was not passed last time is passing now. However this time the problematic condition would not pass |
up |
Hi,
In order to guarantee that the logging process won't block under any circumstance the app,
queue_circular
flag can be used. In that case it can cause loss of events if the queue fills up completely.However sometimes there is a need to handle such cases in some way. That's why I propose adding
queue_overflow_handler
parameter toasyncsender
.Please consider my pull request.
Cheers!