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

Decorator update #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ def sample_job_every_10s():
print "10s job current time : {}".format(time.ctime())
```

## Writing jobs with arguments
```python
@tl.job(interval=timedelta(seconds=5))
def sample_job(idx):
print "Task id: {} | time: {}".format(idx, time.ctime())

# example: queue jobs with different ids
for id in range(1, 3):
task(id)
```

## Start time loop in separate thread
By default timeloop starts in a separate thread.

Expand Down
6 changes: 4 additions & 2 deletions timeloop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ def _stop_jobs(self):

def job(self, interval):
def decorator(f):
self._add_job(f, interval)
return f
def wrapper(*args, **kwargs):
self._add_job(f, interval, *args, **kwargs)
return f
return wrapper
return decorator

def stop(self):
Expand Down