Python-webthing action fadetime +2s

I made a smother action for fading and had troubles because the given duration did not match the time it actually took to fade to the given brightness.

It seems to be somewhere around +2 seconds.

To check if its only my webthing or the examples show the same behavior, I made it more general and tested it with the examples.
It shows the same behavior.

To test that you can change Line 15 to 25 with this code below to ether a single or multiple python-webthing example:

class FadeAction(Action):

    def __init__(self, thing, input_):
        Action.__init__(self, uuid.uuid4().hex, thing, 'fade', input_=input_)

    def perform_action(self):
        # time.sleep(self.input['duration'] / 1000)
        # self.thing.set_property('brightness', self.input['brightness'])
        # self.thing.add_event(OverheatedEvent(self.thing, 102))
        brigthness_after = self.input['brightness']
        brightness_now = self.thing.get_property('brightness')
        if  brigthness_after > brightness_now :
            percentage = brigthness_after - brightness_now
            delay_ms = self.input['duration'] / percentage
  'start incrementing, brightness now %s, brightness afer %s, percentage %s, delay_ms %s, duration %s',brightness_now,brigthness_after,percentage,delay_ms,self.input['duration'])
            while brigthness_after > self.thing.get_property('brightness'):
                time.sleep(delay_ms / 1000)
  'finished incrementing')
        if brigthness_after < brightness_now:
            percentage = brightness_now - brigthness_after
            delay_ms = self.input['duration'] / percentage
  'start decrementing, brightness now %s, brightness afer %s, percentage %s, delay_ms %s, duration %s',
            while brigthness_after < self.thing.get_property('brightness'):
                time.sleep(delay_ms / 1000)
  'finished decrementing')

Then go to the gateway and add the “My Lamp”, click on the thing “My Lamp” and set Brightness to 0 and click on Fade where you set brightness to 100% and duration to 10000ms.

In my case this leads to a 10000ms + ~1500-2000ms duration.

Where do I loose those 2 seconds?