-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add event scheduler #1032
Add event scheduler #1032
Conversation
bf19d95 to
af60315
Compare
penrods
left a comment
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.
Couple minor nitpicks since I think this is gonna be a major API for people to use. Really close, I like it!
mycroft/skills/core.py
Outdated
|
|
||
| def schedule_event(self, handler, datetime, data={}, name=None): | ||
| """ | ||
| schedule a single event |
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.
Minor: Uppercase the first word in these descriptions
mycroft/skills/core.py
Outdated
| Args: | ||
| handler: method to be called | ||
| datetime: time for calling the 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.
Lets write/doc it like this:
when (datetime): when the handler should be called
data (dict, optional): data to send when the handler is called
name (str, optional): friendly name for the event
So rename "datetime" to "when". Make sense?
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.
Nemas problemas, I'll copy this to the wiki as an example for future reference
mycroft/skills/core.py
Outdated
| Args: | ||
| handler: method to be called | ||
| datetime: time for calling the handler | ||
| frequency: time in sconds between calls |
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.
As above for frequency. Can it be a float or just int? Inquiring devs want to know.
==== Tech Notes ==== A single thread handling scheduled events. The skills interact with this using the self.schedule_event() self.schedule_repeating_event self.update_event() and self.remove_event(). This is an improvement over scheduledSkill since each skill creates their own Thread and has to handle storing/restoring scheduled events between starts. All pending events are stored in a json file at shutdown for future sessions. ==== Documentation Notes ==== Needs to be documented ==== Protocol Notes ==== new messagebus event handlers: - mycroft.scheduler.schedule_event - mycroft.scheduler.remove_event - mycroft.scheduler.update_event
af60315 to
7c7fb86
Compare
|
Doc-strings updated |
|
Argh, Codacy is right about the two default values data={}. Bad practice. Let's fix those real quick, just change the defaults to data=None, then add "if data=None: data={}". Good to teach the children well. |
1319ba7 to
11f0544
Compare
|
Yeah, deep down I know this but apparently I've gotten lazy. Good thing we got this bot now :) |
==== Tech Notes ====
A single thread handling scheduled events. The skills interact with this
using the self.schedule_event() self.schedule_repeating_event
self.update_event() and self.remove_event().
This is an improvement over scheduledSkill since each skill creates
their own Thread and has to handle storing/restoring scheduled events
between starts.
All pending events are stored in a json file at shutdown for future
sessions.
==== Documentation Notes ====
Needs to be documented
==== Protocol Notes ====
new messagebus event handlers:
@penrods can you check so I touched all the parts you imagined.