Any positional arguments after the callback will be passed to
the callback when it is called.
"""
- handle = events.make_handle(callback, args)
+ handle = events.Handle(callback, args)
self._ready.append(handle)
return handle
"""Object returned by callback registration methods."""
def __init__(self, callback, args):
+ assert not isinstance(callback, Handle), 'A Handle is not a callback'
self._callback = callback
self._args = args
self._cancelled = False
self = None # Needed to break cycles when an exception occurs.
-def make_handle(callback, args):
- # TODO: Inline this? Or make it a private EventLoop method?
- assert not isinstance(callback, Handle), 'A Handle is not a callback'
- return Handle(callback, args)
-
-
class TimerHandle(Handle):
"""Object returned by timed callback registration methods."""
def add_reader(self, fd, callback, *args):
"""Add a reader callback."""
- handle = events.make_handle(callback, args)
+ handle = events.Handle(callback, args)
try:
key = self._selector.get_key(fd)
except KeyError:
def add_writer(self, fd, callback, *args):
"""Add a writer callback.."""
- handle = events.make_handle(callback, args)
+ handle = events.Handle(callback, args)
try:
key = self._selector.get_key(fd)
except KeyError:
raise AssertionError("Time generator is not finished")
def add_reader(self, fd, callback, *args):
- self.readers[fd] = events.make_handle(callback, args)
+ self.readers[fd] = events.Handle(callback, args)
def remove_reader(self, fd):
self.remove_reader_count[fd] += 1
handle._args, args)
def add_writer(self, fd, callback, *args):
- self.writers[fd] = events.make_handle(callback, args)
+ self.writers[fd] = events.Handle(callback, args)
def remove_writer(self, fd):
self.remove_writer_count[fd] += 1
except ValueError as exc:
raise RuntimeError(str(exc))
- handle = events.make_handle(callback, args)
+ handle = events.Handle(callback, args)
self._signal_handlers[sig] = handle
try:
'<function HandleTests.test_handle.<locals>.callback'))
self.assertTrue(r.endswith('())<cancelled>'), r)
- def test_make_handle(self):
+ def test_handle(self):
def callback(*args):
return args
h1 = asyncio.Handle(callback, ())
self.assertRaises(
- AssertionError, asyncio.events.make_handle, h1, ())
+ AssertionError, asyncio.Handle, h1, ())
@unittest.mock.patch('asyncio.events.logger')
def test_callback_with_exception(self, log):