-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix: add process logs & flush() returns future #27
Conversation
Since we already have a callback function where users can define logs they want to see. If I add a default logger to output every piece of logs in the terminal, it's gonna be a lot. So I store logs to a file For In this case, I got errors in |
src/amplitude/worker.py
Outdated
@@ -39,7 +39,7 @@ def stop(self): | |||
def flush(self): | |||
events = self.storage.pull_all() | |||
if events: | |||
self.threads_pool.submit(self.send, events) | |||
self.send(events) |
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.
@bohan-amplitude are we ok with this?
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.
The difference is flush event using main thread or threadpool. I was changing this because I don't want to block main thread. Right now many unittests need to wait flush finish then verify result. I talked with Xinyi and change back to send won't cause problem for most of the time. I think here it's better to let flush() return future object returned by threads_pool.submit(). In test, use the future object to wait for result before verify. In other use cases returned future can be ignored. @Mercy811 Can you take a look at this and try?
src/amplitude/timeline.py
Outdated
@@ -43,7 +43,7 @@ def remove(self, plugin): | |||
def flush(self): | |||
for destination in self.plugins[PluginType.DESTINATION]: | |||
try: | |||
destination.flush() | |||
return destination.flush() |
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.
Since timeline could have multiple destination plugins, return here may end the function earlier and only return future of first flush call. Should return a list of future for all destination plugins
src/amplitude/client.py
Outdated
@@ -4,6 +4,7 @@ | |||
Amplitude: the Amplitude client class | |||
""" | |||
|
|||
import logging |
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.
unused import
src/test/test_client.py
Outdated
if flush_future: | ||
flush_future.result() |
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.
Extra indent here. Otherwise look good to me.
Summary
Checklist