symfony: Commands not working with pthreads
Symfony version(s) affected: 4.1.4
Description
I want to use Threads in Symfony commands to parallelize processes. Basis for this is the pthreads extension.
Starting a Thread in within a symfony command results in a
Fatal error: Uncaught Exception: Serialization of 'Closure' is not allowed in [no active file]:0
Stack trace:
#0 {main}
thrown in [no active file] on line 0
error. My Thread example does not use any closures.
How to reproduce
Find the code that reproduces the error at: https://github.com/nahpeps/pthreads-example
It encapsulates everything in a docker container.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 18 (7 by maintainers)
I came across this issue today. Spend almost all day trying to debug it. And at this point, it doesn’t look like it is something PSR-4 related. I assume all of us are using
Symfony\Component\Console\Command\Command
in order to run somepthreads
magic. As latest (v3)pthreads
works only in PHPcli
mode. So if i put following code at the top ofexecute
of my command, it fixes the issue:I don’t really want to spend another few days to figure out what is an actual problem and how to fix it. As I think it should be something relatively simple to do for a person who is familiar with Symfony core code. @nicolas-grekas maybe you can help with it?
Meantime, @curry684 @erik404 @nahpeps @fholbrook can any of you confirm this solution works for you too?