diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-15 05:53:42 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-15 05:53:42 +0000 |
commit | 18aec06084e3562c9f3a59771560b2c8896b1cac (patch) | |
tree | 67499349a97d2b102ac0b1f0675ae8c1df356aa6 | |
parent | a94c51a4710b4bf4b7eab49101f52f06e2303555 (diff) |
automatic import of python-pgnotify
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-pgnotify.spec | 281 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 283 insertions, 0 deletions
@@ -0,0 +1 @@ +/pgnotify-0.1.1561372201.tar.gz diff --git a/python-pgnotify.spec b/python-pgnotify.spec new file mode 100644 index 0000000..955b1aa --- /dev/null +++ b/python-pgnotify.spec @@ -0,0 +1,281 @@ +%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.nju.edu.cn/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 +* Mon May 15 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.1561372201-1 +- Package Spec generated @@ -0,0 +1 @@ +ee37c087f0e9e3bbbe84debb257a0888 pgnotify-0.1.1561372201.tar.gz |