Re: Is there any way to listen to NOTIFY in php without polling?
| От | Daniel Verite |
|---|---|
| Тема | Re: Is there any way to listen to NOTIFY in php without polling? |
| Дата | |
| Msg-id | 05e98187-8cda-4e80-9ece-f4c14247d321@mm обсуждение исходный текст |
| Ответ на | Re: Is there any way to listen to NOTIFY in php without polling? (Misa Simic <misa.simic@gmail.com>) |
| Список | pgsql-general |
Misa Simic wrote: > I am not a C developer - was not aware about select()... I was read it as > some kind of sleep... php provides socket_select() as an equivalent to C's select(). See http://php.net/manual/en/function.socket-select.php But it takes "socket resources" as arguments and the postgres php layer does not provides a conversion from the file descriptor returned by PQsocket() to such php socket resources. Thus socket_select() can't be used to monitor a postgres connection. However, you can get a behavior that's close enough in practice to select() with code like this: pg_query($conn, "LISTEN event_name"); while (!$end) { $arr=pg_get_notify($conn); if (!$arr) { usleep(100000); } else // process the notification } This will catch a notification 1/10 second max after it's available and sleep the rest of the time. Best regards, -- Daniel PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org
В списке pgsql-general по дате отправления: