Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

sleep() stops all my Phalcon scripts

I'm using the Long Polling technique for my notification system (a facebook like notification for my single page app with ajax).

I used the sleep(2000) function for every database checking for new notifications:

Controller : notificationsController

Action: indexAction

//sleep for 2 secs

 $notifications = Notifications::find('for_user_id = '.$this->userSession->id);
//some notifications found!
return $notifications

It works well, but the problem is that all my scripts that uses the Phalcon framework are stopped by this sleep(2000),* I mean not only my current Phalcon app, all the phalcon apps that are located in different folders and wait for the boucle to end.*

I think this is a problem from Phalcon ?

Using: WampServer Version 2.2 64bits on Windows 8.1 64bits

edited Apr '14

Here I found a solution for this problem,

you have to use the session_write_close(); for each sleep().

and it's not from Phalcon, sorry for that :)

explanation here: