From 4a080aeec1858cf35228623e0c70943d5a9ef6b9 Mon Sep 17 00:00:00 2001 From: Antoine Rondelet Date: Mon, 20 Aug 2018 18:22:44 +0100 Subject: [PATCH] Fixed wrong import for event loop in separate thread --- docs/filters.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/filters.rst b/docs/filters.rst index 341f926e21..868bef7416 100644 --- a/docs/filters.rst +++ b/docs/filters.rst @@ -242,14 +242,15 @@ entries to a handler. Running the event loop in a separate thread """"""""""""""""""""""""""""""""""""""""""" -Here is an extended version of above example, where the event loop is run in a separate thread, +Here is an extended version of above example, where the event loop is run in a separate thread, releasing the ``main`` function for other tasks. .. code-block:: python from web3.auto import w3 - import sleep from threading import Thread + import time + import asyncio def handle_event(event): @@ -266,6 +267,7 @@ releasing the ``main`` function for other tasks. def main(): loop = asyncio.new_event_loop() + block_filter = w3.eth.filter('latest') worker = Thread(target=log_loop, args=(block_filter, 5), daemon=True) worker.start() # .. do some other stuff