jmettraux / rufus-scheduler

scheduler for Ruby (at, in, cron and every jobs)
MIT License
2.41k stars 201 forks source link

Instances don't work after fork #346

Closed brauliobo closed 6 months ago

brauliobo commented 6 months ago

In the code below:

[1] pry(main)> s=Rufus::Scheduler.new; fork{ s.every('1s'){ puts 'blah' } }
=> 176616

blah will never be printed. If the instance is created inside the fork block then it works.

jmettraux commented 6 months ago

This is as expected.

brauliobo commented 6 months ago

just curious, why? maybe an error should be raised?

jmettraux commented 6 months ago

just curious, why?

Because rufus-scheduler uses threads.

maybe an error should be raised?

You're the first person in 10 or more years to ask for that. If more people were clamouring for it, I would consider that. .

People usually go for sidekiq-cron, solid_queue, whenever, or others. Maybe one of those is what you are looking for.