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
Implement BaseService.run_task(awaitable) #1173
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.
LGTM
65b1f59
to
c0d19de
Compare
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.
Let me know if I'm wrong about the O(n)
memory footprint for the _tasks
API.
await awaitable | ||
except OperationCancelled: | ||
pass | ||
self._tasks.add(asyncio.ensure_future(f())) |
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'm not seeing anywhere that we cleanup finished tasks. Things like Discovery.mayber_connect_to_more_peers
which run periodically will result in an ever growing memory footprint. It looks like we need something to do periodic garbage collection for tasks that are complete.
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.
That's why I used a WeakSet
for self._tasks
; once a task is done there should be no strong reference to it left, and then it is discarded from the set.
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.
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.
That's fancy! 👍
It runs the given awaitable in the background, catches/ignores OperationCancelled and ensures the task is finished before the service is finished. Also removes trinity.Node.add_service() as the same functionality is provided by BaseService.run_child_service() Closes: ethereum#1118
It's no longer needed as of the previous commit
It runs the given awaitable in the background, catches/ignores
OperationCancelled and ensures the task is finished before the
service is finished.
Also removes trinity.Node.add_service() as the same
functionality is provided by BaseService.run_child_service()
Closes: #1118