1

I'm trying to execute a few python scripts in order to manipulate some images on my website. The external program/tool is written in python and is called PHATCH. I'm under Windows and using WAMP as my web server.

Executing only just one script seems to work well, but I need to execute 4 scripts at the same time (to generate 4 different images), my browser will just load and Apache/PHP freezes.

The PHP execution seems to freeze and hung up due several system() calls after each other. Here's an example of how I'm using it:

system("C:\\python\\python.exe C:\\phatch\\phatch.py script1.phatch");
system("C:\\python\\python.exe C:\\phatch\\phatch.py script2.phatch");
system("C:\\python\\python.exe C:\\phatch\\phatch.py script3.phatch");
system("C:\\python\\python.exe C:\\phatch\\phatch.py script4.phatch");

If I only do the first one, it's fine, but as soon as I add the others, it all freezes.

Chris
  • 1,416
  • 18
  • 29
Eric
  • 18,532
  • 2
  • 34
  • 39
  • 1
    Have you tried all four individually? That is, tried script1.phatch, then replaced it with script2.phatch, etc.? It could just be that it's one of the four scripts that's the problem. – Niet the Dark Absol Nov 17 '10 at 19:59
  • You do realize that it's not running all 4 at the same time, right? It's running them serially (one after the other)... The only way around that on Windows is to do something like [this](http://stackoverflow.com/questions/4197579/nohup-on-windows-exec-without-waiting-for-finish-php/4197625#4197625) – ircmaxell Nov 17 '10 at 20:04
  • Have u bothered to check system load in Task Manager? – bcosca Nov 17 '10 at 20:05
  • Yes, all of them works! You see, they work periodly, it will work like 5 times in a row, then it will freeze up. – Eric Nov 17 '10 at 20:14
  • Yes, I do realize they are running serially, but I ment that I needed them to be executed at the same "time", that is, when a user submits a form. – Eric Nov 17 '10 at 20:15
  • If I check the Taskman, only one "cmd.exe" is started when I execute the php-script.. and when it hangs, it stays on one memory usage, its not chewing up my memory or consuming CPU power. – Eric Nov 17 '10 at 20:17

1 Answers1

0

Can multiple copies of phatch be executed simultaneously from the same account? Have you tried this without PHP and Apache?

it is possible that multiple copies starting at the same time access the same files, perhaps use the same temporary files (even with unique names, if the name is based on time, they might have the same name...)

winwaed
  • 7,645
  • 6
  • 36
  • 81
  • Good question! That might be the problem; you see only one "cmd.exe" is started, by other means, only one instance of phatch is started and that's maybe why it freezes.. any idea of how to spawn 4 different calls to the script? – Eric Nov 17 '10 at 20:22
  • 2
    Or another idea reading your comments up at th top: If you want them executed serially, why not simply write a short Python script that runs all four scripts? Then only need one system call. and from an efficiency point of view, Python is only started ONCE! – winwaed Nov 17 '10 at 20:27
  • Oh.. I feel so dumb.. \: I tried that now and it seems to work perfectly! I've tried now like 50 times and no hung so far so I guess that was a solution! THANKS (: – Eric Nov 17 '10 at 21:02