do() or doNormal() will block until the job is accepted by the worker. Looping is only necessary if you care about the response from the job. Use setTimeout() to control how long PHP will block.
If it does timeout, it throws a PHP Warning:
PHP Warning: GearmanClient::do(): _client_do(GEARMAN_TIMEOUT) occured during gearman_client_run_tasks() -> libgearman/client.cc:174