commit 93ac13aafb1d6624ab8a5d2b8ad0bf9bd606264655afeced5dd81b85a2245f6a Author: Matej Cepl Date: Sat Jan 2 02:11:11 2021 +0000 Accepting request 859775 from home:mcepl:work Looks like a good addition to asyncio. OBS-URL: https://build.opensuse.org/request/show/859775 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-unsync?expand=0&rev=1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/python-unsync.changes b/python-unsync.changes new file mode 100644 index 0000000..0408291 --- /dev/null +++ b/python-unsync.changes @@ -0,0 +1,4 @@ +------------------------------------------------------------------- +Sat Jan 2 01:40:00 UTC 2021 - Matej Cepl + +- Initial packaging of unsync 1.3. diff --git a/python-unsync.spec b/python-unsync.spec new file mode 100644 index 0000000..73d0163 --- /dev/null +++ b/python-unsync.spec @@ -0,0 +1,77 @@ +# +# spec file for package python-unsync +# +# Copyright (c) 2021 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + +%define skip_python2 1 +%{?!python_module:%define python_module() python-%{**} python3-%{**}} +%define modname unsync +Name: python-unsync +Version: 1.3 +Release: 0 +Summary: Unsynchronize asyncio +License: MIT +URL: https://github.com/alex-sherman/unsync +Source: https://github.com/alex-sherman/%{modname}/archive/v%{version}.tar.gz#/%{modname}-%{version}.tar.gz +BuildRequires: %{python_module setuptools} +BuildRequires: fdupes +BuildRequires: python-rpm-macros +BuildArch: noarch +%python_subpackages + +%description +# unsync +Unsynchronize `asyncio` by using an ambient event loop in a separate thread. + +# Rules for unsync +1. Mark all async functions with `@unsync`. May also mark regular + functions to execute in a separate thread. + * All `@unsync` functions, async or not, return an `Unfuture` +2. All `Futures` must be `Unfutures` which includes the result of an + `@unsync` function call, or wrapping `Unfuture(asyncio.Future)` or + `Unfuture(concurrent.Future)`. `Unfuture` combines the behavior of + `asyncio.Future` and `concurrent.Future`: + * `Unfuture.set_value` is threadsafe unlike `asyncio.Future` + * `Unfuture` instances can be awaited, even if made from + `concurrent.Future` + * `Unfuture.result()` is a blocking operation *except* in + `unsync.loop`/`unsync.thread` where it behaves like + `asyncio.Future.result` and will throw an exception if the future + is not done +3. Functions will execute in different contexts: + * `@unsync` async functions will execute in an event loop in + `unsync.thread` + * `@unsync` regular functions will execute in + `unsync.thread_executor`, a `ThreadPoolExecutor` + * `@unsync(cpu_bound=True)` regular functions will execute in + `unsync.process_executor`, a `ProcessPoolExecutor` + +%prep +%setup -q -n unsync-%{version} + +%build +%python_build + +%install +%python_install +%python_expand %fdupes %{buildroot}%{$python_sitelib} + +%check +%pyunittest -v + +%files %{python_files} +%{python_sitelib}/* + +%changelog diff --git a/unsync-1.3.tar.gz b/unsync-1.3.tar.gz new file mode 100644 index 0000000..fcbcc84 --- /dev/null +++ b/unsync-1.3.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1c585a7b5e108b89cb40ef2af99fe10ba49011a81985dfea100305c13c5b839 +size 8284