-
Notifications
You must be signed in to change notification settings - Fork 659
Feature socketcan bcm owned by bus #412
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
Conversation
can/bus.py
Outdated
| self._lock_send_periodic = threading.Lock() | ||
| return ThreadBasedCyclicSendTask(self, self._lock_send_periodic, msg, period, duration) | ||
| task = ThreadBasedCyclicSendTask(self, self._lock_send_periodic, msg, period, duration) | ||
| self._periodic_tasks.append(task) |
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’ve discussed this before but this can potentially become a memory leak. There is not way for the user to clean out stopped tasks. I don't know what to do about it. Maybe it could be possible to remove them if they are stopped, because then we know that the application has its own reference to the task.
| The kernel's broadcast manager will be used. | ||
| The kernel's broadcast manager will be used and the task will | ||
| be active while this Bus instance is still in scope. |
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.
...or shutdown() or stop_all_periodic_tasks() is called?
|
Note: We might also consider calling |
Codecov Report
@@ Coverage Diff @@
## develop #412 +/- ##
===========================================
+ Coverage 61.51% 62.43% +0.91%
===========================================
Files 55 55
Lines 4584 4600 +16
===========================================
+ Hits 2820 2872 +52
+ Misses 1764 1728 -36 |
|
Hmm okay what about this slightly hack approach of wrapping the |
|
Regarding the memory leak issue at the least we should clearly document what the user can do to prevent it, but I'd rather have an api that allows the user to take ownership for the task management if they want to. Perhaps a flag in the bus initializer or the |
d342f46 to
2e734b2
Compare
can/bus.py
Outdated
| self.shutdown() | ||
|
|
||
| def __del__(self): | ||
| self.shutdown() |
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.
Not all implementations may be able to handle shutdown being called twice.
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.
Fair point - I'd rather remove the __del__ from the bus instead of adding shutdown state tracking. Do you agree?
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 think so too.
5189764 to
76dc836
Compare
Keep list of tasks with the bus. Implement the stop all perodic tasks.
76dc836 to
4660091
Compare
|
I think this is pretty much ready - I've just rebased. The last change I made - added a |
|
I just merged this. Someone else (@christiansandberg ?) needs to have a look at #292 and #404. |
Competes with #409 because I forgot to look if you were already doing this @christiansandberg !
Bus. By default tasks created withbus.send_periodicwill have a reference held by the bus - this means in many cases the user doesn't need to keep the task in scope for their periodic messages to continue being sent. If this behavior isn't desired passstore_task=Falseto thesend_periodicmethod.stop_all_periodic_tasksmethod