Skip to content
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

Cron #60

Merged
merged 39 commits into from
Jun 11, 2014
Merged

Cron #60

merged 39 commits into from
Jun 11, 2014

Conversation

barrucadu
Copy link
Contributor

cron.

(cron)

…name and some args to call it with when the time is up, and there is just one repeating task (the scheduler) which handles everything. This is to allow saving things to the database, although that isn't done yet.
# shouldn't get this far anyway, killing the bot is worse.
try:
func(taskdef['time'], *taskdef['args'], **taskdef['kwargs'])
except:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be except Exception: - just using except: will catch everything, including important signals like KeyboardInterrupt (which the Twisted reactor handles to shutdown gracefully). except Exception as e: would even give you the exception instead of having to poke sys.exc_info().

@alanbriolat
Copy link
Member

I wonder if the task definition could be restructured somewhat to remove some duplication of information?

key description
owner name of plugin that created the task
name name of the task (shouldn't contain owner)
when datetime to trigger the task at
interval (optional) reschedule at when + interval when task is triggered, if absent/None task does not repeat
callback (optional) call owner.callback(*args, **kwargs) when task triggers, if absent/None use owner.name(*args, **kwargs)
args (optional) callback positional arguments
kwargs (optional) callback keyword arguments

Are there cases you were considering where you might want a task name not tied to a plugin name, or triggering callbacks on other plugins?

@alanbriolat alanbriolat merged commit 2aefb06 into HackSoc:master Jun 11, 2014
@barrucadu barrucadu deleted the cron branch June 11, 2014 23:15
@alanbriolat alanbriolat mentioned this pull request Jun 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants