View previous topic :: View next topic |
Author |
Message |
krusty_ar Guru
Joined: 03 Oct 2002 Posts: 560 Location: Rosario, Argentina
|
Posted: Tue Feb 17, 2004 4:48 pm Post subject: "Multithreaded" PHP |
|
|
Hi, I have a php script that I run in apache2 (with PHP 4.3.3). The script takes a long time to complete, but each work unit can be done in parallel without problems and the task is not CPU bounded, so my idea was to invoke the script in several browser windows and use a marker in the db so each script processes the next free work unit, the thing is, when I run a second browser, it waits for the previous to finish and then starts running. Is there a way to avoid this without being forced to run other copies from different boxes', I don't even know what is the criteria to determine when to wait or not (IP, domain, etc).
The function that I'm interested in parallelizing is @fsockopen.
Maybe this has something to do: I'm flushing the page with status updates.
Do you have any suggestions on how to make this work or know why is this happening? _________________ I am Beta, don't expect correct behaviour from me.
Take part of the adopt an unaswered post initiative |
|
Back to top |
|
|
orionrobots Apprentice
Joined: 07 Oct 2003 Posts: 289 Location: London, Uk
|
Posted: Tue Feb 17, 2004 9:21 pm Post subject: Why not try |
|
|
Spawning/forking or executing a seperate script/program. A PHP script can use exec to run external points.
With PHP shell scripting, you may still work with PHP(as that is what you are comfortable with), in such a way that you may kick off a large task in a browser window, but not need to keep that window open to continue the task. You would then output the data to a log, and have a URL which displays the output. You could even have the script email its log to the user.
Try something like this:
Code: | exec("php script.php parameters 2>dev/null >&- <&- >/dev/null &"); |
You may also be able to use the backtick operator in this way.
Orion _________________ Danny Staple, curator of http://orionrobots.co.uk
Adopt an unanswered post initiative https://forums.gentoo.org/search.php?search_id=unanswered |
|
Back to top |
|
|
krusty_ar Guru
Joined: 03 Oct 2002 Posts: 560 Location: Rosario, Argentina
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|