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

Help, it doesn't work! #97

Closed
brendt opened this issue Dec 17, 2019 · 1 comment
Closed

Help, it doesn't work! #97

brendt opened this issue Dec 17, 2019 · 1 comment
Labels

Comments

@brendt
Copy link
Contributor

brendt commented Dec 17, 2019

I've decided it would be good to make a dedicated issue explaining about what this package does and doesn't do. Lots of people open keep opening the same kind of issue, so I hope to explain it once and for all in this one.

Sometimes your async tasks don't work, they throw strange errors and what not. It's important to realise how tasks are run asynchronously. Each task is a new PHP process created on the fly, which can execute time-consuming code. This package aims to run these kinds of time consuming tasks in parallel, so that instead of waiting 60 seconds for 10 6-seconds tasks to finish, you could run 10 processes at the same time, finishing the task in 6 seconds (actually it's a little more because process management also adds some overhead).

That's rule number one: this package is only useful if you're dealing with several tasks which take at least a few seconds each to process.

So what about strange errors you don't understand? Since parallel tasks are executed in their own process, there's no concept of a booted framework. I often see people trying to use Laravel models in tasks, while they don't realise Laravel doesn't exist in these child processes. You can of course boot Laravel, or whatever framework you want, manually in child processes, though chances are your use case isn't what this package is meant for.

That's rule number two: parallel tasks are run in clean PHP processes, there's no concept of a framework unless you boot it manually within that task.

In case you need lots of framework-specific functionality, I'd suggest to first look at the existing queueing systems of your framework, instead of using this package.

@brendt brendt pinned this issue Dec 17, 2019
@spatie spatie locked as resolved and limited conversation to collaborators Dec 17, 2019
@spatie-bot
Copy link

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants