Nothing posted here so far will help with that. If the 3 CPU-second limit is for only one process, you can avoid it by breaking up the job into several smaller jobs, then executing all of them; or by monitoring how much CPU time you've used, and right before you use your quota up simply forking a new process and continuing the work there. Here's a small code snippet that demonstrates this forking; note that it abuses signal handlers, and so may not work on all platforms. It generates 10,000,000 pseudorandom numbers, printing every 1,000,000th. It should run the same with or without forking.
The fun part about this approach is that it's actually much harder on the server than if they just let you bypass the stupid limit. If you're lucky, they'll notice this and work with you to make your and their lives better. If you're unlucky, they'll just shut off your account.
If the limit is on that child and all of its children, you're pretty much screwed.
Apart from hack value, though, the real solution is to make your code more efficient, or else find a hosting provider that better meets your needs.
| [reply] [d/l] |
It's not so much my code that's inefficient, as it is the two Image::Magick calls for resizing and writing the image.
Thanks for your help everybody. I really appreciate it. I'll look into abusing signal handlers and forking, and see if I can't get them to let me use a little more cpu time. Though, that doesn't really help out if this eventually goes to other places that also impose cpu restrictions.
-Scott
| [reply] |
what about using sleep() ?
or Time::HiRes::sleep() ?
| [reply] |