robdmc / crontabs Goto Github PK
View Code? Open in Web Editor NEW:alarm_clock: A cron-like utility for Python
License: MIT License
:alarm_clock: A cron-like utility for Python
License: MIT License
I think I can get the process to re-spawn every run by
wrapping the returned self.loop in self.get_target to have the kwarg max_iter=1
How does the effect of the seconds
argument to every
differ from the seconds argument to run
in :
Tab(name='my_slow_job').every(seconds=20).run(my_job, 'slow', seconds=20),
as part of
Cron().schedule(
# Turn off logging for job that runs every five seconds
Tab(name='my_fast_job', verbose=False).every(seconds=5).run(my_job, 'fast', seconds=5),
# Go ahead and let this job emit logging messages
Tab(name='my_slow_job').every(seconds=20).run(my_job, 'slow', seconds=20),
).go()
hi, robdmc. I really appreciate your work.
I found crontabs yesterday, but I couldn't get 'staring()' method working.
I digged a little and found that changes in the latest commit break the "starting()" method.
I'm now using version 0.2.1, everything works fine.
The idea here is that the user can specify
def weekends(timestamp):
return timestamp.weekay() in [5, 6]
or
def work_hours(timestamp):
return 8 =< time.stamp.hour <= 17
Then
Cron(
Tab(name='my_job').every(hour=1).excluding(weekends).during(work_hours)
).go()
Used example in PyCharm 2020.1 on Windows 10
def my_job(*args, **kwargs):
print('args={} kwargs={} running at {}'.format(args, kwargs, datetime.datetime.now()))
Cron().schedule(
Tab(name='run_my_job').every(seconds=5).run(my_job, 'my_arg', my_kwarg='hello')
).go()
After trying stopping a console it looks like the job is still running but just without calling my_job
Refactor the SubProcess
class to actually use threading instead of subprocesses. Then run each invocation of the scheduled function in its own process. This will force python to release memory to OS after each run of the scheduled function.
Cron().schedule(
# Turn off logging for job that runs every five seconds
Tab(name='first_job', verbose=True).every(
seconds=5).run(my_job, 'first', seconds=5),
Tab(name='second_job', verbose=True).every(
seconds=15).run(my_job, 'second', seconds=15),
).go()
as shown,
2022-11-16 12:13:40,003 [35667] INFO first_job: Running first_job
args=('first',) kwargs={'seconds': 5} running at 2022-11-16 12:13:40.003657
2022-11-16 12:13:45,004 [35667] INFO first_job: Running first_job
2022-11-16 12:13:45,005 [35668] INFO second_job: Running second_job
args=('first',) kwargs={'seconds': 5} running at 2022-11-16 12:13:45.005105
args=('second',) kwargs={'seconds': 15} running at 2022-11-16 12:13:45.005147
second job always slower than first job, I am willing to PR but I have no idea how to improve it,
@robdmc could you share me some though on how to improve this to become asycn process task?
I was going to use your library for a project but I don't see a way to look up jobs and stop them. I looked @ the schedule library and it supports it: https://schedule.readthedocs.io/en/stable/faq.html#how-can-i-cancel-several-jobs-at-once Did I miss something in the code/documentation or is this feature not supported?
Think about giving Tab a new method stopping_at(<datetime or string>)
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.