This is a workaround for the bug in psycopg2 described here
This adds additional polling after the notification processing.