diff options
author | Zac Medico <zmedico@gentoo.org> | 2018-07-17 20:36:59 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2018-07-17 20:40:05 -0700 |
commit | a7c7af98d755f34e84d1f0f847e2c0d5cc5b7e2f (patch) | |
tree | 379dbdfc148b68816a6a7fe4fad837f067a98b05 | |
parent | EventLoop: use python2.7 compatible **kwargs for call_* context arg (diff) | |
download | portage-a7c7af98.tar.gz portage-a7c7af98.tar.bz2 portage-a7c7af98.zip |
EventLoop: raise TypeError for unexpected call_* keyword args
-rw-r--r-- | pym/portage/util/_eventloop/EventLoop.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pym/portage/util/_eventloop/EventLoop.py b/pym/portage/util/_eventloop/EventLoop.py index 084ff0c18..ffd12cff9 100644 --- a/pym/portage/util/_eventloop/EventLoop.py +++ b/pym/portage/util/_eventloop/EventLoop.py @@ -859,11 +859,23 @@ class EventLoop(object): @return: a handle which can be used to cancel the callback @rtype: asyncio.Handle (or compatible) """ + try: + unexpected = next(key for key in kwargs if key != 'context') + except StopIteration: + pass + else: + raise TypeError("call_soon() got an unexpected keyword argument '%s'" % unexpected) return self._handle(self._idle_add( self._call_soon_callback(callback, args)), self) def call_soon_threadsafe(self, callback, *args, **kwargs): """Like call_soon(), but thread safe.""" + try: + unexpected = next(key for key in kwargs if key != 'context') + except StopIteration: + pass + else: + raise TypeError("call_soon_threadsafe() got an unexpected keyword argument '%s'" % unexpected) # idle_add provides thread safety return self._handle(self.idle_add( self._call_soon_callback(callback, args)), self) @@ -909,6 +921,12 @@ class EventLoop(object): @return: a handle which can be used to cancel the callback @rtype: asyncio.Handle (or compatible) """ + try: + unexpected = next(key for key in kwargs if key != 'context') + except StopIteration: + pass + else: + raise TypeError("call_later() got an unexpected keyword argument '%s'" % unexpected) return self._handle(self.timeout_add( delay * 1000, self._call_soon_callback(callback, args)), self) @@ -936,6 +954,12 @@ class EventLoop(object): @return: a handle which can be used to cancel the callback @rtype: asyncio.Handle (or compatible) """ + try: + unexpected = next(key for key in kwargs if key != 'context') + except StopIteration: + pass + else: + raise TypeError("call_at() got an unexpected keyword argument '%s'" % unexpected) delta = when - self.time() return self.call_later(delta if delta > 0 else 0, callback, *args) |