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

Event loop incorrectly inherited in child processes. #75155

Closed
elprans mannequin opened this issue Jul 19, 2017 · 2 comments
Closed

Event loop incorrectly inherited in child processes. #75155

elprans mannequin opened this issue Jul 19, 2017 · 2 comments
Labels
topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@elprans
Copy link
Mannequin

elprans mannequin commented Jul 19, 2017

BPO 30972
Nosy @elprans, @1st1
Files
  • test.py: Example
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2017-07-19.22:49:35.008>
    labels = ['type-bug', 'expert-asyncio']
    title = 'Event loop incorrectly inherited in child processes.'
    updated_at = <Date 2017-07-19.22:49:35.008>
    user = 'https://github.com/elprans'

    bugs.python.org fields:

    activity = <Date 2017-07-19.22:49:35.008>
    actor = 'Elvis.Pranskevichus'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['asyncio']
    creation = <Date 2017-07-19.22:49:35.008>
    creator = 'Elvis.Pranskevichus'
    dependencies = []
    files = ['47024']
    hgrepos = []
    issue_num = 30972
    keywords = []
    message_count = 1.0
    messages = ['298693']
    nosy_count = 2.0
    nosy_names = ['Elvis.Pranskevichus', 'yselivanov']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue30972'
    versions = ['Python 3.6']

    @elprans
    Copy link
    Mannequin Author

    elprans mannequin commented Jul 19, 2017

    The attached example shows that asyncio.get_event_loop still returns parent process' event loop in some cases. It appears that the fix in issue bpo-29703 was incomplete:

    PARENT PID: 21947, LOOP: <_UnixSelectorEventLoop running=True closed=False debug=False> at 0x7f0fbe7cfd68
    WORKER PID: 21948, LOOP: <_UnixSelectorEventLoop running=True closed=False debug=False> at 0x7f0fbe7cfd68
    concurrent.futures.process._RemoteTraceback:
    """
    Traceback (most recent call last):
      File "/usr/lib64/python3.6/concurrent/futures/process.py", line 175, in _process_worker
        r = call_item.fn(*call_item.args, **call_item.kwargs)
      File "test.py", line 13, in worker
        return loop.run_until_complete(worker_coro())
      File "/usr/lib64/python3.6/asyncio/base_events.py", line 454, in run_until_complete
        self.run_forever()
      File "/usr/lib64/python3.6/asyncio/base_events.py", line 408, in run_forever
        raise RuntimeError('This event loop is already running')
    RuntimeError: This event loop is already running
    """
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "test.py", line 25, in <module>
        loop.run_until_complete(main())
      File "/usr/lib64/python3.6/asyncio/base_events.py", line 466, in run_until_complete
        return future.result()
      File "test.py", line 21, in main
        return await loop.run_in_executor(executor, worker)
    RuntimeError: This event loop is already running

    @elprans elprans mannequin added topic-asyncio type-bug An unexpected behavior, bug, or error labels Jul 19, 2017
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @kumaraditya303
    Copy link
    Contributor

    Fixed on main branch:

    @kumaraditya303 ➜ /workspaces/cpython (main ✗) $ ./python main.py 
    PARENT PID: 11366, LOOP: <_UnixSelectorEventLoop running=True closed=False debug=False> at 0x7fafe6565280
    /workspaces/cpython/main.py:11: DeprecationWarning: There is no current event loop
      loop = asyncio.get_event_loop()
    WORKER PID: 11367, LOOP: <_UnixSelectorEventLoop running=False closed=False debug=False> at 0x7fafe6e29550
    Running coro in process 11367

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-asyncio type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant