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

Conflict with running event loop in Jupyter #278

Open
abbass2 opened this issue Jun 10, 2022 · 2 comments
Open

Conflict with running event loop in Jupyter #278

abbass2 opened this issue Jun 10, 2022 · 2 comments

Comments

@abbass2
Copy link

abbass2 commented Jun 10, 2022

Describe the bug
Error running in Jupyter which already has a running event loop

To Reproduce
Steps to reproduce the behavior:
Run the following code in Jupyter:

from secedgar.core import DailyFilings
from secedgar import client
from datetime import date
from secedgar.cik_lookup import get_cik_map

USER_AGENT = 'ambrus.com/sec-edgar/sec-edgar'

nc = client.NetworkClient(user_agent=USER_AGENT, rate_limit=5)

def get_form_4(filing_entry):
    return filing_entry.form_type.lower() in ("3", "4")

daily_filings = DailyFilings(date=date(2022, 3, 10), client=nc, entry_filter=get_form_4)
ciks_map = get_cik_map()
daily_filings.save('./daily_filings/')

Expected behavior
You get the following error

    576     def _check_running(self):
    577         if self.is_running():
--> 578             raise RuntimeError('This event loop is already running')
    579         if events._get_running_loop() is not None:
    580             raise RuntimeError(

RuntimeError: This event loop is already running

Desktop (please complete the following information):
macOS

Additional context
Can be fixed with the following code in the last lines of _index.py

            loop = asyncio.get_event_loop()
            if not loop.is_running():
                loop.run_until_complete(self.client.wait_for_download_async(inputs))
            else:
                loop.create_task(self.client.wait_for_download_async(inputs))
@gooseyman
Copy link

Petiesmo is correct about this being an IDE issue - I think this issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@abbass2 @gooseyman and others