blob: cdba793c1e9c787164bdc082233312b4c6331ab0 [file] [log] [blame]
Scott Bakerbef5fd92019-02-21 10:24:02 -08001#
2# Copyright 2017 the original author or authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
Zack Williams5c2ea232019-01-30 15:23:01 -070016from __future__ import absolute_import
Scott Bakerbef5fd92019-02-21 10:24:02 -080017from twisted.internet import reactor
18from twisted.internet.defer import Deferred
19
20
21def asleep(dt):
22 """
23 Async (event driven) wait for given time period (in seconds)
24 :param dt: Delay in seconds
25 :return: Deferred to be fired with value None when time expires.
26 """
27 d = Deferred()
28 reactor.callLater(dt, lambda: d.callback(None))
Zack Williams5c2ea232019-01-30 15:23:01 -070029 return d