[webkit-reviews] review granted: [Bug 229148] [webkitcorepy] Add Defer object : [Attachment 435612] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 17 16:34:08 PDT 2021


dewei_zhu at apple.com has granted Jonathan Bedard <jbedard at apple.com>'s request
for review:
Bug 229148: [webkitcorepy] Add Defer object
https://bugs.webkit.org/show_bug.cgi?id=229148

Attachment 435612: Patch

https://bugs.webkit.org/attachment.cgi?id=435612&action=review




--- Comment #3 from dewei_zhu at apple.com ---
Comment on attachment 435612
  --> https://bugs.webkit.org/attachment.cgi?id=435612
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=435612&action=review

> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/defer.py:24
> +class Defer(object):

It might cause confusion with "Deferred" in twisted module, which is more about
async operation.
For this one, we want to defer the evaluation of 'callback', this is more like
lazily evaluated. 
This also limits the callback to be a callable that takes no argument, would
that work for what it's designed for?

> Tools/Scripts/libraries/webkitcorepy/webkitcorepy/tests/defer_unittest.py:34
> +

Maybe we also want to have a test case that the evaluation is actually
deferred.

value = []
d = Defer(lambda: value.append('foo'))
self.assertEqual(len(value), 0)
d.value
self.assertEqual(len(value), 1)
self.assertEqual(value[0], 'foo').


More information about the webkit-reviews mailing list