reactphp / reactphp

Event-driven, non-blocking I/O with PHP.

Home Page:https://reactphp.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reactphp non blocking cron

dejanmilosevic0 opened this issue · comments

Is it possible to make non blocking cron jobs with reactphp and how?

If we add multuple periodic timers with some functions to do, will they be independent?

Absolutely! Just make sure each "function" will be async and not block the loop and there's nothing which prevents you form scheduling your timers to run at specific times 👍

I hope this helps! 👍

How can i make functions async because they aren't async and they are blocking loop. I have periodic timer which runs every second, but function takes about 2 seconds to compute everything, and then timer is late and runs every 2 seconds instead.

You should make sure your "function" is async and it should not block the loop. If this is not possible, you may want to move it to a separate process (ChildProcess component) or use a queue 👍