Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed wrong import for event loop in separate thread #1010

Merged
merged 1 commit into from
Aug 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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