%global _empty_manifest_terminate_build 0 Name: python-pgnotify Version: 0.1.1561372201 Release: 1 Summary: Easily LISTEN to PostgreSQL NOTIFY notifications License: Unlicense URL: https://github.com/djrobstep/pgnotify Source0: https://mirrors.aliyun.com/pypi/web/packages/79/23/01bc239fd97b399373b639a20f04082cb062fb566dd116f953d9c270f2a2/pgnotify-0.1.1561372201.tar.gz BuildArch: noarch Requires: python3-psycopg2-binary Requires: python3-logx %description # pgnotify: A python library to easily LISTEN to PostgreSQL NOTIFY notifications ## Example LISTEN to and process NOTIFY events with a simple `for` loop, like so: ```python from pgnotify import await_pg_notifications for notification in await_pg_notifications( 'postgresql:///example', ['channel1', 'channel2']): print(notification.channel) print(notification.payload) ``` ## Install Installable with any python package manager from the python package index, eg: ```shell pip install pgnotify ``` ## All the bells and whistles You can also handle timeouts and signals, as in this more fully-fleshed example: ```python import signal from pgnotify import await_pg_notifications, get_dbapi_connection # the first parameter of the await_pg_notifications # loop is a dbapi connection in autocommit mode CONNECT = "postgresql:///example" # use this convenient method to create the right connection # from a database URL e = get_dbapi_connection(CONNECT) SIGNALS_TO_HANDLE = [signal.SIGINT, signal.SIGTERM] for n in await_pg_notifications( e, ["hello", "hello2"], timeout=10, yield_on_timeout=True, handle_signals=SIGNALS_TO_HANDLE, ): # the integer code of the signal is yielded on each # occurrence of a handled signal if isinstance(n, int): sig = signal.Signals(n) print(f"handling {sig.name}, stopping") break # the `yield_on_timeout` option makes the # loop yield `None` on timeout elif n is None: print("timeout, continuing") # handle the actual notify occurrences here else: print((n.pid, n.channel, n.payload)) ``` Further documentation to come. %package -n python3-pgnotify Summary: Easily LISTEN to PostgreSQL NOTIFY notifications Provides: python-pgnotify BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-pgnotify # pgnotify: A python library to easily LISTEN to PostgreSQL NOTIFY notifications ## Example LISTEN to and process NOTIFY events with a simple `for` loop, like so: ```python from pgnotify import await_pg_notifications for notification in await_pg_notifications( 'postgresql:///example', ['channel1', 'channel2']): print(notification.channel) print(notification.payload) ``` ## Install Installable with any python package manager from the python package index, eg: ```shell pip install pgnotify ``` ## All the bells and whistles You can also handle timeouts and signals, as in this more fully-fleshed example: ```python import signal from pgnotify import await_pg_notifications, get_dbapi_connection # the first parameter of the await_pg_notifications # loop is a dbapi connection in autocommit mode CONNECT = "postgresql:///example" # use this convenient method to create the right connection # from a database URL e = get_dbapi_connection(CONNECT) SIGNALS_TO_HANDLE = [signal.SIGINT, signal.SIGTERM] for n in await_pg_notifications( e, ["hello", "hello2"], timeout=10, yield_on_timeout=True, handle_signals=SIGNALS_TO_HANDLE, ): # the integer code of the signal is yielded on each # occurrence of a handled signal if isinstance(n, int): sig = signal.Signals(n) print(f"handling {sig.name}, stopping") break # the `yield_on_timeout` option makes the # loop yield `None` on timeout elif n is None: print("timeout, continuing") # handle the actual notify occurrences here else: print((n.pid, n.channel, n.payload)) ``` Further documentation to come. %package help Summary: Development documents and examples for pgnotify Provides: python3-pgnotify-doc %description help # pgnotify: A python library to easily LISTEN to PostgreSQL NOTIFY notifications ## Example LISTEN to and process NOTIFY events with a simple `for` loop, like so: ```python from pgnotify import await_pg_notifications for notification in await_pg_notifications( 'postgresql:///example', ['channel1', 'channel2']): print(notification.channel) print(notification.payload) ``` ## Install Installable with any python package manager from the python package index, eg: ```shell pip install pgnotify ``` ## All the bells and whistles You can also handle timeouts and signals, as in this more fully-fleshed example: ```python import signal from pgnotify import await_pg_notifications, get_dbapi_connection # the first parameter of the await_pg_notifications # loop is a dbapi connection in autocommit mode CONNECT = "postgresql:///example" # use this convenient method to create the right connection # from a database URL e = get_dbapi_connection(CONNECT) SIGNALS_TO_HANDLE = [signal.SIGINT, signal.SIGTERM] for n in await_pg_notifications( e, ["hello", "hello2"], timeout=10, yield_on_timeout=True, handle_signals=SIGNALS_TO_HANDLE, ): # the integer code of the signal is yielded on each # occurrence of a handled signal if isinstance(n, int): sig = signal.Signals(n) print(f"handling {sig.name}, stopping") break # the `yield_on_timeout` option makes the # loop yield `None` on timeout elif n is None: print("timeout, continuing") # handle the actual notify occurrences here else: print((n.pid, n.channel, n.payload)) ``` Further documentation to come. %prep %autosetup -n pgnotify-0.1.1561372201 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-pgnotify -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Thu Jun 08 2023 Python_Bot - 0.1.1561372201-1 - Package Spec generated