Skip to content

Commit

Permalink
Fixed wrong import for event loop in separate thread
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineRondelet committed Aug 20, 2018
1 parent e95e9f6 commit 4a080ae
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 4a080ae

Please sign in to comment.