by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 21 2018 04:00
    sagebind closed #8
  • Sep 21 2018 04:00
    sagebind closed #7
  • Mar 20 2018 13:46
    henrywood edited #25
  • Mar 20 2018 13:45
    henrywood edited #25
  • Mar 20 2018 13:44
    henrywood opened #25
  • May 17 2017 09:57
    pentatonicfunk commented #21
  • May 17 2017 09:56
    pentatonicfunk commented #21
  • May 17 2017 08:11
    pentatonicfunk edited #21
  • May 17 2017 08:10
    pentatonicfunk opened #21
  • May 06 2017 13:13
    pentatonicfunk opened #14
  • Mar 17 2017 01:54
    trowski closed #17
  • Mar 17 2017 01:53

    trowski on master

    Deprecation notice (compare)

  • Feb 24 2017 21:17

    trowski on master

    Deprecation notice (compare)

  • Feb 24 2017 21:07

    trowski on master

    Deprecation notice (compare)

  • Dec 10 2016 00:53
    tak3r opened #5
  • Nov 29 2016 08:28
    lhfeng edited #6
  • Nov 29 2016 08:26
    lhfeng opened #6
  • Nov 23 2016 21:58
    lukaszwit commented #23
  • Nov 23 2016 21:58
    lukaszwit commented #23
  • Nov 23 2016 21:54
    lukaszwit commented #23
Honza Machala
@HonzaMac
Thank for help!
Honza Machala
@HonzaMac
@trowski when I’ve put there all() for coroutines, app stop to sending info to websockets. Do you have any idea, why that happen?
I’ve catched all rejections in ->done(fn, fn); so there shouldn’t be reason for that. You can check it on github.
Douglas Reith
@redthor
Hi there, a bit of a newbie... I have a class with an array of tasks. On the class is a long running method to process the tasks. I'd like to process them in parallel
I have tested something like this:
    public function doLongRunningFn($x)
    {
        sleep(2);
        echo "\n$x\n";
    }

    public function testFlush(array $tasks)
    {
        $that = $this;

        $longRunningFn = function ($calculateThis) use ($that) {
            (yield $that->doLongRunningFn($calculateThis));
        };

        $coroutines = [];

        foreach ($tasks as $task) {
            $coroutines[] = new \Icicle\Coroutine\Coroutine($longRunningFn($task));
        }

        $allDone = \Icicle\Awaitable\all($coroutines);
        $allDone->then(function () use ($that) {
            $that->clear();
        })->done();

        \Icicle\Loop\run();
    }
But it appears as though it runs synchronously - perhaps I need to use the Concurrent package?
Aaron Piotrowski
@trowski
@HonzaMac Not sure what you did wrong, it's not jumping out at me on GitHub (unless you already fixed it).
Aaron Piotrowski
@trowski
@redthor Yes, you'd need to use the concurrent package to run a blocking task (in your example, sleep() blocks the process). yield does not run a coroutine in a separate process or thread, it only waits until a yielded coroutine or awaitable is resolved.
Douglas Reith
@redthor
great, thanks, I'm trying the concurrent package now
is libev still recommended when using the concurrent package?
Aaron Piotrowski
@trowski
I think it will work fine... but try with and without it.
Douglas Reith
@redthor
thanks
btw, will the Parcels approach work with Processes as well as Threads ? https://icicle.io/docs/manual/concurrency/#synchronization-with-parcels
I'm finding installing threads difficult! :)
Aaron Piotrowski
@trowski
I have run into issues with libev and the postgres package, so there might be something that needs fixing in the extension.
The SharedMemoryParcel class should work with processes.
Douglas Reith
@redthor
ok, thanks for your help - I'll try that example with Processes
Aaron Piotrowski
@trowski
Be sure to check out the Worker, Pool, and Task features of concurrent. They make running tasks concurrently easy and take the hassles out of set up since it automatically detects what methods are available for spawning workers.
Just write the blocking task in the run() method of a class implementing Task, then enqueue the task to a worker.
Douglas Reith
@redthor
great advice! Will do - by the way my aim is basically to combine the results of an external service API query with a potentially slow database query and returns the results to the user (as opposed to doing the two sequentially)
Aaron Piotrowski
@trowski
Then I think workers would be exactly what you're looking for.
Douglas Reith
@redthor
ace, thanks Aaron.
Aaron Piotrowski
@trowski
No problem. Let me know if you run into any trouble.
Douglas Reith
@redthor
Just fyi I'm going to follow this example https://github.com/icicleio/concurrent/blob/master/examples/worker-pool.php (but the php5 version)
Aaron Piotrowski
@trowski
That's a good example of running multiple simple blocking tasks concurrently.
Douglas Reith
@redthor
I presume the Loop\periodic() call isn't necessary? It's just for the example?
Oh, and the unreference() - should I keep that call?
Aaron Piotrowski
@trowski
Right, it's just to show that the main thread isn't blocked.
Douglas Reith
@redthor
ok, thanks
Aaron Piotrowski
@trowski
unreference() removes the reference to the timer from the loop, so the loop automatically exists even though the timer is running.
Douglas Reith
@redthor
ah right
In my use case I don't mind if the main process is blocking because I need to get back both sets of results - should I change anything?
btw I have my test running :)
Aaron Piotrowski
@trowski
The main process will wait within the coroutine on the call to Awaitable\all($coroutines) but it doesn't block the process. You probably don't have to change anything though.
Douglas Reith
@redthor
great, thanks
Douglas Reith
@redthor
Ah the service that retrieves the results is not serializable - Serialization of 'Closure' is not allowed - I'll have to look at doing this another way
Honza Machala
@HonzaMac
@trowski I’m there. I’v pushed that into github
Honza Machala
@HonzaMac
So, when I put sendStatus()(aka fetchInit()) into Coroutine (to start them at once) it stopped working and I’receive in websocket opcode -1
Pavel Chebotarev
@nexor
@trowski I've tested postgres package at dev-master branch and it works perfectly at first sight.
Honza Machala
@HonzaMac
Hi @nexor . What kind of operations are you using with pg?
Pavel Chebotarev
@nexor
Simple insert for now
Honza Machala
@HonzaMac
I’m goingo to use this pg library to change our architecture ans speed up it. So I want know if its ready fro production :)
Pavel Chebotarev
@nexor
Not sure, in my opinion it is ready for production when it has version 1.x.x ;)
I'm using Icicle in my pet projects only, so I can afford any errors.
Honza Machala
@HonzaMac
Did you experienced some real bad errors?
Honza Machala
@HonzaMac

Hi all, how could i catch exception throwen from ->timeout() and not cancell all awaitables, but just few? @trowski
i’ve similar code to this:

                $coroutine = new Coroutine($generator);
                $coroutine->then(null, function (){
                    return 'aaaa';
                });
                yield $coroutine;

but it still keeps cancelling all the rest of code.

Pavel Chebotarev
@nexor

Did you experienced some real bad errors?

No. There is very basic functional and it works very good.

Honza Machala
@HonzaMac
Anybody here? :)
Aaron Piotrowski
@trowski
@HonzaMac $coroutine->then() returns another awaitable, so you should be yielding to that awaitable instead.
$coroutine = new Coroutine($generator);
$awaitable = $coroutine->then(null, function (){
    return 'aaaa';
});
yield $awaitable;
Honza Machala
@HonzaMac
Ah! I missed that @trowski thanks :]