1 |
commit: a7c7af98d755f34e84d1f0f847e2c0d5cc5b7e2f |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jul 18 03:36:59 2018 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jul 18 03:40:05 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a7c7af98 |
7 |
|
8 |
EventLoop: raise TypeError for unexpected call_* keyword args |
9 |
|
10 |
pym/portage/util/_eventloop/EventLoop.py | 24 ++++++++++++++++++++++++ |
11 |
1 file changed, 24 insertions(+) |
12 |
|
13 |
diff --git a/pym/portage/util/_eventloop/EventLoop.py b/pym/portage/util/_eventloop/EventLoop.py |
14 |
index 084ff0c18..ffd12cff9 100644 |
15 |
--- a/pym/portage/util/_eventloop/EventLoop.py |
16 |
+++ b/pym/portage/util/_eventloop/EventLoop.py |
17 |
@@ -859,11 +859,23 @@ class EventLoop(object): |
18 |
@return: a handle which can be used to cancel the callback |
19 |
@rtype: asyncio.Handle (or compatible) |
20 |
""" |
21 |
+ try: |
22 |
+ unexpected = next(key for key in kwargs if key != 'context') |
23 |
+ except StopIteration: |
24 |
+ pass |
25 |
+ else: |
26 |
+ raise TypeError("call_soon() got an unexpected keyword argument '%s'" % unexpected) |
27 |
return self._handle(self._idle_add( |
28 |
self._call_soon_callback(callback, args)), self) |
29 |
|
30 |
def call_soon_threadsafe(self, callback, *args, **kwargs): |
31 |
"""Like call_soon(), but thread safe.""" |
32 |
+ try: |
33 |
+ unexpected = next(key for key in kwargs if key != 'context') |
34 |
+ except StopIteration: |
35 |
+ pass |
36 |
+ else: |
37 |
+ raise TypeError("call_soon_threadsafe() got an unexpected keyword argument '%s'" % unexpected) |
38 |
# idle_add provides thread safety |
39 |
return self._handle(self.idle_add( |
40 |
self._call_soon_callback(callback, args)), self) |
41 |
@@ -909,6 +921,12 @@ class EventLoop(object): |
42 |
@return: a handle which can be used to cancel the callback |
43 |
@rtype: asyncio.Handle (or compatible) |
44 |
""" |
45 |
+ try: |
46 |
+ unexpected = next(key for key in kwargs if key != 'context') |
47 |
+ except StopIteration: |
48 |
+ pass |
49 |
+ else: |
50 |
+ raise TypeError("call_later() got an unexpected keyword argument '%s'" % unexpected) |
51 |
return self._handle(self.timeout_add( |
52 |
delay * 1000, self._call_soon_callback(callback, args)), self) |
53 |
|
54 |
@@ -936,6 +954,12 @@ class EventLoop(object): |
55 |
@return: a handle which can be used to cancel the callback |
56 |
@rtype: asyncio.Handle (or compatible) |
57 |
""" |
58 |
+ try: |
59 |
+ unexpected = next(key for key in kwargs if key != 'context') |
60 |
+ except StopIteration: |
61 |
+ pass |
62 |
+ else: |
63 |
+ raise TypeError("call_at() got an unexpected keyword argument '%s'" % unexpected) |
64 |
delta = when - self.time() |
65 |
return self.call_later(delta if delta > 0 else 0, callback, *args) |