python-dispatch 0.2.2__py3-none-any.whl → 0.2.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pydispatch/aioutils.py +21 -3
- pydispatch/dispatch.py +10 -8
- pydispatch/utils.py +8 -2
- {python_dispatch-0.2.2.dist-info → python_dispatch-0.2.3.dist-info}/METADATA +16 -16
- python_dispatch-0.2.3.dist-info/RECORD +9 -0
- python_dispatch-0.2.3.dist-info/WHEEL +4 -0
- python_dispatch-0.2.2.dist-info/LICENSE.txt +0 -21
- python_dispatch-0.2.2.dist-info/RECORD +0 -11
- python_dispatch-0.2.2.dist-info/WHEEL +0 -5
- python_dispatch-0.2.2.dist-info/top_level.txt +0 -1
pydispatch/aioutils.py
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
|
+
import sys
|
|
1
2
|
import asyncio
|
|
2
3
|
import threading
|
|
3
|
-
from
|
|
4
|
-
from
|
|
4
|
+
from weakref import ref
|
|
5
|
+
from _weakref import _remove_dead_weakref # type: ignore[import]
|
|
6
|
+
if sys.version_info < (3, 14):
|
|
7
|
+
from _weakrefset import _IterationGuard
|
|
8
|
+
else:
|
|
9
|
+
# _IterationGuard was removed in Python 3.14. We define a no-op version here
|
|
10
|
+
class _IterationGuard:
|
|
11
|
+
def __init__(self, obj):
|
|
12
|
+
pass
|
|
13
|
+
def __enter__(self):
|
|
14
|
+
pass
|
|
15
|
+
def __exit__(self, *args):
|
|
16
|
+
pass
|
|
17
|
+
|
|
5
18
|
|
|
6
19
|
from pydispatch.utils import (
|
|
7
20
|
WeakMethodContainer,
|
|
8
21
|
isfunction,
|
|
9
22
|
get_method_vars,
|
|
10
|
-
_remove_dead_weakref,
|
|
11
23
|
)
|
|
12
24
|
|
|
13
25
|
|
|
@@ -192,6 +204,12 @@ class AioWeakMethodContainer(WeakMethodContainer):
|
|
|
192
204
|
_remove_dead_weakref(self.data, wr.key)
|
|
193
205
|
self._on_weakref_fin(wr.key)
|
|
194
206
|
self._remove = remove
|
|
207
|
+
|
|
208
|
+
# `_pending_removals` and `_iterating` were removed in Python 3.14.
|
|
209
|
+
# To maintain compatibility with earlier versions, we reintroduce them here.
|
|
210
|
+
self._pending_removals = []
|
|
211
|
+
self._iterating = set()
|
|
212
|
+
|
|
195
213
|
self.event_loop_map = {}
|
|
196
214
|
def add_method(self, loop, callback):
|
|
197
215
|
"""Add a coroutine function
|
pydispatch/dispatch.py
CHANGED
|
@@ -209,14 +209,16 @@ class Dispatcher(object):
|
|
|
209
209
|
... async def on_foo_test_event(self, *args, **kwargs):
|
|
210
210
|
... self.got_foo_event.set()
|
|
211
211
|
|
|
212
|
-
>>>
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
212
|
+
>>> async def main():
|
|
213
|
+
... loop = asyncio.get_running_loop()
|
|
214
|
+
... foo = Foo()
|
|
215
|
+
... bar = Bar()
|
|
216
|
+
... foo.bind(test_event=bar.on_foo_test_event, __aio_loop__=loop)
|
|
217
|
+
... fut = asyncio.create_task(bar.wait_for_foo())
|
|
218
|
+
... foo.emit('test_event')
|
|
219
|
+
... await fut
|
|
220
|
+
|
|
221
|
+
>>> asyncio.run(main())
|
|
220
222
|
got foo!
|
|
221
223
|
|
|
222
224
|
This can also be done using :meth:`bind_async`.
|
pydispatch/utils.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import weakref
|
|
2
|
-
from weakref import ref
|
|
3
|
-
from _weakref import
|
|
2
|
+
from weakref import ref
|
|
3
|
+
from _weakref import _remove_dead_weakref # type: ignore[import]
|
|
4
4
|
import types
|
|
5
5
|
import asyncio
|
|
6
6
|
|
|
@@ -114,6 +114,12 @@ class InformativeWVDict(weakref.WeakValueDictionary):
|
|
|
114
114
|
_remove_dead_weakref(self.data, wr.key)
|
|
115
115
|
self._data_del_callback(wr.key)
|
|
116
116
|
self._remove = remove
|
|
117
|
+
|
|
118
|
+
# `_pending_removals` and `_iterating` were removed in Python 3.14.
|
|
119
|
+
# To maintain compatibility with earlier versions, we reintroduce them here.
|
|
120
|
+
self._pending_removals = []
|
|
121
|
+
self._iterating = set()
|
|
122
|
+
|
|
117
123
|
self.data = InformativeDict()
|
|
118
124
|
self.data.del_callback = self._data_del_callback
|
|
119
125
|
def _data_del_callback(self, key):
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-dispatch
|
|
3
|
-
Version: 0.2.
|
|
4
|
-
Summary: Lightweight Event Handling
|
|
5
|
-
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: Lightweight Event Handling Library for Python
|
|
5
|
+
Keywords: event,properties,dispatch
|
|
6
6
|
Author: Matthew Reid
|
|
7
|
-
Author-email: matt@nomadic-recording.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Project-URL: Documentation, https://python-dispatch.readthedocs.io
|
|
10
|
-
Project-URL: Source, https://github.com/nocarryr/python-dispatch
|
|
11
|
-
Project-URL: Tracker, https://github.com/nocarryr/python-dispatch/issues
|
|
12
|
-
Keywords: event properties dispatch
|
|
13
|
-
Platform: any
|
|
7
|
+
Author-email: Matthew Reid <matt@nomadic-recording.com>
|
|
8
|
+
License-Expression: MIT
|
|
14
9
|
Classifier: Development Status :: 3 - Alpha
|
|
15
10
|
Classifier: Intended Audience :: Developers
|
|
16
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
17
11
|
Classifier: Operating System :: OS Independent
|
|
18
12
|
Classifier: Programming Language :: Python
|
|
19
13
|
Classifier: Topic :: Software Development
|
|
20
14
|
Classifier: Programming Language :: Python :: 3
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
23
15
|
Classifier: Programming Language :: Python :: 3.8
|
|
24
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
25
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
26
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
27
22
|
Classifier: Topic :: Software Development :: Libraries
|
|
28
23
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Dist: importlib-metadata ; python_full_version < '3.8'
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Project-URL: Documentation, https://python-dispatch.readthedocs.io/
|
|
27
|
+
Project-URL: Download, https://pypi.org/project/python-dispatch/
|
|
28
|
+
Project-URL: Source, https://github.com/nocarryr/python-dispatch
|
|
29
|
+
Project-URL: Tracker, https://github.com/nocarryr/python-dispatch/issues
|
|
29
30
|
Description-Content-Type: text/markdown
|
|
30
|
-
License-File: LICENSE.txt
|
|
31
31
|
|
|
32
32
|
# python-dispatch
|
|
33
33
|
Lightweight event handling for Python
|
|
34
34
|
|
|
35
|
-
[](https://github.com/astral-sh/uv)[](https://coveralls.io/github/nocarryr/python-dispatch?branch=master)[](https://badge.fury.io/py/python-dispatch)[](https://raw.githubusercontent.com/nocarryr/python-dispatch/master/LICENSE.txt)
|
|
36
36
|
|
|
37
37
|
## Description
|
|
38
38
|
This is an implementation of the "Observer Pattern" with inspiration from the
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
pydispatch/__init__.py,sha256=qt4QDOYq_QGq0bMZizAvnhhzLr7LkZe9PBHilTjc74Y,2190
|
|
2
|
+
pydispatch/aioutils.py,sha256=tv-ddi8tMwqtOJGNqONYb2Y-PKXyOJG4wsX3EzmgBsw,9848
|
|
3
|
+
pydispatch/decorators.py,sha256=FFts0T9wvTVAgC9KGZSkpn_Nneecl1gAzufgP6nI4iQ,4213
|
|
4
|
+
pydispatch/dispatch.py,sha256=Jbb7bl7kdsXlfQsCM8Jehui7qpSH1GhawEgPLk-lyAo,13508
|
|
5
|
+
pydispatch/properties.py,sha256=Pt4J32bqz3xT5BwmIO3Idl8vmkNbei2R0g_Vqwi7RH0,13138
|
|
6
|
+
pydispatch/utils.py,sha256=ubuGYHi0rxNS_Dbhqftfyr6yANS0OlaB6Ni9_x_kEP4,6535
|
|
7
|
+
python_dispatch-0.2.3.dist-info/WHEEL,sha256=ZyFSCYkV2BrxH6-HRVRg3R9Fo7MALzer9KiPYqNxSbo,79
|
|
8
|
+
python_dispatch-0.2.3.dist-info/METADATA,sha256=S1e1HF_lMN-gVv80kfCMUgbLVTNtLNslwkaW1A6NMsA,5802
|
|
9
|
+
python_dispatch-0.2.3.dist-info/RECORD,,
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2016 Matthew Reid
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
pydispatch/__init__.py,sha256=qt4QDOYq_QGq0bMZizAvnhhzLr7LkZe9PBHilTjc74Y,2190
|
|
2
|
-
pydispatch/aioutils.py,sha256=aDva5oh_VV5Rkfc-NWI8cR5ut-91t0engnv781z9zsk,9270
|
|
3
|
-
pydispatch/decorators.py,sha256=FFts0T9wvTVAgC9KGZSkpn_Nneecl1gAzufgP6nI4iQ,4213
|
|
4
|
-
pydispatch/dispatch.py,sha256=lkBvZVbUmFppvEiCO2n-_61TmJ-awHA4tRsq_-p6alA,13429
|
|
5
|
-
pydispatch/properties.py,sha256=Pt4J32bqz3xT5BwmIO3Idl8vmkNbei2R0g_Vqwi7RH0,13138
|
|
6
|
-
pydispatch/utils.py,sha256=BtsIfRJxweCRDJHnXiR8YTXLF9c7DJy7tVF3isL4n3A,6286
|
|
7
|
-
python_dispatch-0.2.2.dist-info/LICENSE.txt,sha256=muuSBeZ0K6AotNoWadQaHzGO9CtXBFBemAsXRL170tA,1069
|
|
8
|
-
python_dispatch-0.2.2.dist-info/METADATA,sha256=XOQqOwQ1KYMsnlgSXMdZShaWOlv1fAI-hbbZCXxjGTE,5558
|
|
9
|
-
python_dispatch-0.2.2.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
|
10
|
-
python_dispatch-0.2.2.dist-info/top_level.txt,sha256=BW69gM2IyIPfFk8J13eRwxzVlic046roE3WH5bya5BI,11
|
|
11
|
-
python_dispatch-0.2.2.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pydispatch
|