From 30c7559d3a558b8a84311cc3ec3b5548154512ac Mon Sep 17 00:00:00 2001 From: Kay Kurokawa Date: Thu, 9 Feb 2017 11:22:23 -0500 Subject: [PATCH] adding reactor.callLater as a utils function --- CHANGELOG.md | 1 + lbrynet/core/utils.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35182d916..65fb03666 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ at anytime. \#\# [0.8.6rc0] - 2017-02-19 ### Changed * Add `file_get` by stream hash + * Add utils.call_later to replace reactor.callLater ### * Fix unhandled error in `get` * Fix sd blob timeout handling in `get_availability`, return 0.0 diff --git a/lbrynet/core/utils.py b/lbrynet/core/utils.py index 76d542b36..a581ebd15 100644 --- a/lbrynet/core/utils.py +++ b/lbrynet/core/utils.py @@ -45,6 +45,13 @@ def datetime_obj(*args, **kwargs): return datetime.datetime(*args, **kwargs) +def call_later(delay, func, *args, **kwargs): + # Import here to ensure that it gets called after installing a reator + # see: http://twistedmatrix.com/documents/current/core/howto/choosing-reactor.html + from twisted.internet import reactor + return reactor.callLater(delay, func, *args, **kwargs) + + def generate_id(num=None): h = get_lbry_hash_obj() if num is not None: