Skip to content

Commit

Permalink
Merge pull request #1010 from AntoineRondelet/fix/import
Browse files Browse the repository at this point in the history
Fixed wrong import for event loop in separate thread
  • Loading branch information
dylanjw authored Aug 20, 2018
2 parents e95e9f6 + 4a080ae commit 6ffc959
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/filters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit 6ffc959

Please sign in to comment.