Skip to content

Create Unique Task Decorator #1

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

Closed
stephengolub opened this issue Aug 12, 2020 · 3 comments
Closed

Create Unique Task Decorator #1

stephengolub opened this issue Aug 12, 2020 · 3 comments

Comments

@stephengolub
Copy link

The convention of declaring task.unique(‘function_name’) seems a bit non-pythonic.

I feel like it might be better to create a @unique decorator that ensures that the method it wraps is only run once.

Could even add a param that will control what that means:

  • @unique or @unique(“restart”) would kill the previous run
  • @unique(“queue”) would enqueue subsequent calls.

I’m sure there are more cases, just spit-balling.

@craigbarratt
Copy link
Member

Thanks for the great suggestion - I totally missed the idea of making unique a decorator. That's much more natural. I don't think there are many cases where the task.unique() function would be in the middle of some code, but I'll keep it around just in case that's needed. Let me think about the specific decorator name and arguments. I'm working on supporting Jupyter as a pyscript frontend currently, and I'll get to this after that.

@craigbarratt
Copy link
Member

I created a wiki with some roadmap ideas, and I added this idea to that list. So closing this issue.

@craigbarratt
Copy link
Member

Just did commit 59a5461 that adds @task_unique as a new decorator. Its arguments are the same as task.unique().

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

No branches or pull requests

2 participants