Questions tagged [amphp]
Amp is a non-blocking concurrency framework for PHP applications.
60
questions
0
votes
0
answers
40
views
Parallel function call in php
Is there a way to execute internal functions in parallel in PHP?
For example, I have four functions:
function a(){
return 1;
}
function b(){
return 2;
}
function c(){
return 3;
}
...
0
votes
0
answers
38
views
How to continue performing asynchronous actions after return in php?
I'm just a beginner, please tell me if it is possible to return the result from a php function, but at the same time so that asynchronous actions continue to work in it using the amphp library?
...
0
votes
1
answer
57
views
Amphp parallel adding lots of amp-parallel sock files in php-fpm tmp folder
I am using the following code to submit workers into the queue and then run them with Task.
$executions = [];
foreach ($urls as $url) {
// FetchTask is just an example, you'll have to implement
...
0
votes
1
answer
114
views
Using Amphp with a framework such as Magento
I am trying to use Amphp Parallel functions with the Magento framework in a custom module.
try {
$response = wait(parallelMap($items, function ($item) use ($arg1){
$this->getCustomItems(...
1
vote
1
answer
588
views
Do i really have to restart the server everytime i made changes?
i want to use AMP PHP and create a Project. So i started with one of the examples on github and i can see hello world.
Now if i make changes to my code, i have to restart everytime the server. but ...
0
votes
1
answer
490
views
amphp: Promises in Loops
Sorry, guys, but I'm kinda getting crazy now spending Hours and just can't figure out what's wrong.
So I have a download class which needs to separate the download in chunks and then request each ...
0
votes
1
answer
1k
views
AMP Parallel: failed to open stream: Too many open files in ClassLoader.php
While using AMPHP libraries for thread working tasks, I suddenly got the Warning and Error:
PHP Warning: include(/.../vendor/amphp/process/lib/ProcessException.php): failed to open stream: Too many ...
1
vote
1
answer
456
views
PHP global scope and Amp async parallel execution
I'm using AMP ParallelFunctions and AMP Promise wait to create an async execution in PHP. The idea is to call multiple HTTP endpoints simultaneously and wait until all of them are resolved.
The code ...
0
votes
1
answer
366
views
amphp auto-load class not working as expected
I'm trying to use a custom class in a worker using amphp but it doesn't seem to be working. The below class is already auto-loaded using composer. Please help me out with this issue. My code is below:
...
0
votes
2
answers
568
views
PHP Amp\Mysql async slower than native blocking PDO?
I'm doing some testing with Amp and try to see how it could help speeding up SQL Queries by running them async. I think I'm doing something wrong because the results of this test file are very ...
2
votes
0
answers
112
views
Count of working workers less then maximum pool size
Good day. I use amphp parallel-functions. I set the maximum pool size to 128 - the number of workers is stable at 128.
I set it to 256 - I get different values for the number of working workers from ...
0
votes
1
answer
169
views
AmPHP buffer keeps going forever
I've just picked up AmPHP and I'm trying to get the post body from my AmPHP http server, however, it keeps going forever (just never sends back a response to my client).
This is the code I'm currently ...
0
votes
1
answer
303
views
amphp libary works on xampp but not on my webhoster
i want to execute domains in an array parallel. It works but only by xampp and not on my webhost. Why?
I use this:
https://github.com/amphp/parallel
Code:
<?php
require __DIR__ . '/../vendor/...
2
votes
1
answer
116
views
AMPHP throws an uncatchable MultiReasonException - Is this a bug?
I'm getting a MultiReasonException thrown during a DNS lookup as part of a AMP Socket connect call. The actual exception thrown is an NX domain, which is fine - the lookup is for a host which is down ...
2
votes
1
answer
943
views
AMPHP - Queueing more Tasks than available Workers in Pool
I have a project in which I am converting a large amount of .tif images into PDF documents. File count goes into millions.
To speed up the process I am using Amphp. Since the process of converting the ...
1
vote
0
answers
170
views
How to use amphp/parallel async call to fetch data from databases and another function to fetch data parallelly
amphp/parallel
How to use amphp/parallel async call to fetch data from databases or from another function to fetch data parallelly
i have done research on the github but didn't find anything
0
votes
0
answers
163
views
How to make post request with Artax
I am testing abilities php using laravel/lumen as server side framework. I have exisitng project and new task is to make multiple requests at the same time. I found amphp/parallel package which could ...
0
votes
2
answers
912
views
Amphp : Run many async loops with same connection (eventstore client)
I'm using eventstore client which uses amphp. I need inside my application to reuse the connection in many parts.
So I created a connection provider:
public function getConnection(): ...
0
votes
1
answer
750
views
AMPHP HTTP Client with usage proxies
I'm trying to use AMPHP HTTP-Client with proxies, and I cannot make it work.
I'm using the example from their GitHub. (https://github.com/amphp/http-tunnel/blob/master/examples/http-client-via-proxy....
0
votes
1
answer
315
views
Problems with amphp with more than 1k concurrent tcp requests
I have created an application using the https://amphp.org framework. It is running with the help of a cronjob (every 5 minutes) sending a concurrent request to some sensors (temperatures) and it saves ...
1
vote
2
answers
185
views
How to print output to two different terminals in php?
I am running two for loops in parallel using amphp/parallel-functions. I am wondering how can I see the live output printing parallelly? I am thinking of printing to two different terminals. Can it be ...
1
vote
0
answers
789
views
How to run methods in Parallel in php without using any extension?
Is it possible to run two methods in parallel without using any extension like pthread or pcntl?
I tried Symfony/Process but it seems like I can use it only for php cli programing.
My requirement ...
0
votes
1
answer
534
views
Get websocket pings from an open stream connection using Amp\Websocket?
I am using the readme example here:
https://github.com/amphp/websocket-client/blob/master/README.md
use Amp\Websocket;
use Amp\Delayed;
use Amp\Websocket\Connection;
use Amp\Websocket\Handshake;
use ...
3
votes
0
answers
1k
views
Error while using Amphp parallel with user defined function
I am trying to call a user-defined function using Worker\enqueueCallable.
I have put the function in a separate file and used composer to autoload it.
And I am getting the error :
Fatal error: ...
3
votes
1
answer
435
views
Class Amp non found
I'm new on amphp and i'd like to try this very simple code first.
I downloaded amphp with composer for windows and save all folder created inside my project folder.
composer require amphp/http-client
...
3
votes
2
answers
3k
views
How the Amphp parallel works?
I was reading about amphp, and I had a doubt about parallel
Example code:
<?php
require __DIR__ . '/vendor/autoload.php';
$client = new Amp\Artax\DefaultClient;
$promises = [];
$urls = [
"...
1
vote
2
answers
167
views
Are there limitations in mysqli that make it unsuitable for use with AMP or ReactPHP?
I've seen that libraries such as amphp/mysql and friends-of-reactphp/mysql implement the low-level MySQL protocol, and do not rely on any built-in extension.
Given that mysqli supports async queries, ...
0
votes
1
answer
516
views
How to catch a php websocket broken TCP connection exception with Amphp?
Here is the current WebSocket loop I'm running while the connection is still alive. But after 11 hours of continuous connection, I received an exception
"exception":"[object] (Amp\\Websocket\\...
0
votes
2
answers
705
views
How to send a message to ReactPHP/Amp/Swoole/etc. from PHP-FPM?
I'm thinking about making a worker script to handle async tasks on my server, using a framework such as ReactPHP, Amp or Swoole that would be running permanently as a service (I haven't made my choice ...
2
votes
1
answer
981
views
How to call class method inside worker CallableTask in amphp/parallel Amp\Loop?
I'm using the Amp\Loop and want to know that what is the correct way of calling class method with arguments in $worker->enqueue(new CallableTask()).
Here is an example:
<?php
require_once "vendor/...
1
vote
2
answers
2k
views
How to use amphp/parallel library for non-blocking process
I want to use the amphp/parallel library for non-blocking process. I have a simple download file function which does a curl hit to the remote image file and save it to the local. I'm hitting this ...
3
votes
1
answer
228
views
How to create a callable method/function in PHP
I'm trying to achieve multitasking in PHP.
At the moment I'm evaluating AMPHP framework, and in particular paralell and paralel-functions.
But I can't figure how is to create a method callable...
...
0
votes
1
answer
307
views
MultiReason Exception in amphp/paralell
I'm trying to call multiples request to some webservices.
And I can't figure out how to do this.
I'm getting this error:
Amp\MultiReasonException
Multiple errors encountered
I'm trying with ...
0
votes
0
answers
36
views
how to consume webservices with amphp/artax?
i'm new to amphp/artax
I need to consume several web services in paralell, and join the answers togheter.
I achieved request several pages with :
....
$response = ...
0
votes
1
answer
736
views
PHP Amp/Parallel. Please give me example about parallel function with pool
I have been stuck in my task about running functions in parallel. I has tried this library multi-threading pthreads from krakjoe, but I has limit knowledge about installations in ubuntu. I has tried ...
0
votes
1
answer
65
views
Getting the response from HttpKernel for an url, parallelized
I am using https://github.com/JosephSilber/page-cache to cache pages. To prepare pages beforehand (about 100,000), I used to run 8 http requests in parallel via GuzzleHttp. It worked, but was pretty ...
2
votes
2
answers
1k
views
Async http call with php
I have a situation where I have a loop, that is going to read chunk of data from a file, send those chunk to a rest api, and continue until the EOF, but I want this to be async inside the loop, so, I ...
0
votes
0
answers
45
views
Where to put amphp directory?
I downloaded amphp using composer and it automatically downloaded it toC:\Users\<myusername> is that where it's meant to be for usage or do I need to copy it to my local servers directory or ...
1
vote
0
answers
115
views
Google API PHP library files.get in parallel
I want to run files.list to get the files list on a users Drive, and then run files.get in parallel to download the files. The problem is that when the parallel operation is preceded by a single ...
0
votes
1
answer
930
views
How to redirect amp form on submission to another page?
Below mentioned code is my form code
<form class="contact100-form validate-form" method="post" action-xhr="https://www.aptadvantage.com/popup_2.php">
<div class="wrap-input100 validate-...
1
vote
1
answer
241
views
Multiprocessing in php using zend framework 3
Is it possible to multiprocess/multithread in php from a http request.
Background
I am working on a project where I expect some data (not from a user so data upload is consistent) to be uploaded to ...
0
votes
1
answer
815
views
How to correctly turn closure to promise in amphp?
I'm learning amphp. I want to convert sync call to async call using event loop in amphp. My sample code use file_get_contents as sample blocking call.
Using sync call, it look like this:
$uris = [
...
0
votes
1
answer
125
views
Socket concurrency in PHP
I would like to know if anyone has any good insight into how to open a number of sockets to the same server, write and then read data concurrently in PHP. Should I use a concurrency framework like ...
0
votes
2
answers
334
views
Amphp Artax bug
i used following very basic example of amphp/artax
$URL can be any url e.g. http://www.yahoo.com
$promises[$URI] = Amp\call(function () use ($client, $URI) {
// "yield" inside a ...
-1
votes
1
answer
208
views
Create Iterator from array with AMPHP
I have an array in php:
$array = [1,2,3];
When I do:
while(yield $array->advance())
I get Call to a member function advance() on array
How do I turn my array into an iterator?
1
vote
2
answers
2k
views
Cannot get ReactPHP promises to execute asynchronously
I have a PHP script that processes data downloaded from multiple REST APIs into a standardized format and builds an array or table of this data. The script currently executes everything synchronously ...
2
votes
0
answers
2k
views
How to implement amphp/websocket-client in laravel
I am trying to get the datafeed from Kite Connect via async web socket. I think that I can use amphp/websocket-client library in my Laravel project but I am clueless where to begin.
How to integrate ...
0
votes
1
answer
43
views
How to get data from Aerys parseBody if the data doesn't have key
I am working with Aerys but I have a problem. When I send my parameters through post I don't know how to access to the data.
In the documentation they use the following function:
$body = yield ...
1
vote
1
answer
64
views
Gracefully stopping generators
Consider the following code:
Loop::run(function() {
Loop::onSignal(SIGINT, function () use ($w) {
echo "Caught SIGINT! exiting ...\n";
Loop::stop();
});
while([$jobId, $...
0
votes
1
answer
132
views
Why am I getting "Error: Call to a member function end() on null" using Aerys?
I'm trying to put aerys on top of my cms but getting error.
As I see the backend returns not null value - #1 in stacktrace but it doesn't reach $resp->end().
I'm stucked trying to get that value to ...