GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — all deprecation warnings are disabled for the whole process while new unix asyncio subprocesses are created · Issue #98327 · python/cpython

all deprecation warnings are disabled for the whole process while new unix asyncio subprocesses are created #98327

New issue
Copy link
New issue
Copy link
Closed
Closed
all deprecation warnings are disabled for the whole process while new unix asyncio subprocesses are created#98327
Copy link
Labels
3.12only security fixesonly security fixestopic-asyncio

Description

@graingert
graingert
opened on Oct 16, 2022
Issue body actions

on python3.10 the following prints:

python3.10 demo.py 
/home/graingert/projects/cpython/demo.py:40: DeprecationWarning: demo warning
  warnings.warn("demo warning", DeprecationWarning)
/home/graingert/projects/cpython/demo.py:48: DeprecationWarning: demo warning2
  warnings.warn("demo warning2", DeprecationWarning)

but on python main it prints:

./python demo.py      
/home/graingert/projects/cpython/demo.py:40: DeprecationWarning: demo warning
  warnings.warn("demo warning", DeprecationWarning)
import sys
import threading
import asyncio
import concurrent.futures
import warnings


async def acreate_process_then_sleep(started_event, stop_event):
    event = asyncio.Event()

    async def create_process():
        loop = asyncio.get_running_loop()
        loop.call_soon(event.set)
        proc = await asyncio.create_subprocess_exec(
            sys.executable,
            "-c",
            "print('hello')",
            stdin=None,
            stdout=asyncio.subprocess.PIPE,
            stderr=asyncio.subprocess.STDOUT,
        )
        await proc.communicate()

    async def sleep():
        await event.wait()
        started_event.set()
        stop_event.wait()

    await asyncio.gather(create_process(), sleep())


def create_process_then_sleep(*args, **kwargs):
    asyncio.run(acreate_process_then_sleep(*args, **kwargs))


def main():
    with concurrent.futures.ThreadPoolExecutor() as tpe:
        stop_event = threading.Event()
        started_event = threading.Event()
        warnings.warn("demo warning", DeprecationWarning)
        fut = tpe.submit(
            create_process_then_sleep,
            started_event=started_event,
            stop_event=stop_event,
        )
        try:
            started_event.wait()
            warnings.warn("demo warning2", DeprecationWarning)
        finally:
            stop_event.set()
            fut.result()


if __name__ == "__main__":
    sys.exit(main())

Originally posted by @graingert in #98215 (comment)

Activity

  1. graingert
    added
    3.12only security fixesonly security fixes
    topic-asyncio
    on Oct 16, 2022
  2. graingert commented on Oct 16, 2022

    @graingert
    graingert
    on Oct 16, 2022
    ContributorAuthor
    More actions

    cc @kumaraditya303

  3. ezio-melotti
    added this to asyncioon Oct 16, 2022
  4. ezio-melotti
    moved this to Todo in asyncioon Oct 16, 2022
  5. graingert
    changed the title [-]all deprecation warnings are disabled for the whole process while new unix asyncio processes are created[/-] [+]all deprecation warnings are disabled for the whole process while new unix asyncio subprocesses are created[/+] on Oct 16, 2022
  6. graingert commented on Oct 16, 2022

    @graingert
    graingert
    on Oct 16, 2022
    ContributorAuthor
    More actions

    see also #91505, #81785 and #50896

  7. kumaraditya303 commented on Oct 16, 2022

    @kumaraditya303
    kumaraditya303
    on Oct 16, 2022
    Contributor
    More actions

    Okay, I'll be AFK for some time so feel free to create a PR. I doubt that any one will hit this in practise though.

  8. gvanrossum commented on Oct 16, 2022

    @gvanrossum
    gvanrossum
    on Oct 16, 2022
    Member
    More actions

    Ah, I guess I was right about that context manager. :-)

  9. kumaraditya303
    self-assigned this
    on Oct 16, 2022
  10. kumaraditya303 commented on Oct 16, 2022

    @kumaraditya303
    kumaraditya303
    on Oct 16, 2022
    Contributor
    More actions

    #98333 fixes this, I had underestimated warnings module :-)

  11. gvanrossum
    added a commit that references this issue on Oct 17, 2022

    GH-98327: Reduce scope of catch_warnings() in _make_subprocess_transp…

    72c10d3
  12. gvanrossum commented on Oct 17, 2022

    @gvanrossum
    gvanrossum
    on Oct 17, 2022
    Member
    More actions

    We're still looking for a perfect solution (see discussion in PR), so keeping this issue open.

  13. kumaraditya303
    assigned
    graingert
    and unassigned
    kumaraditya303
    on Oct 17, 2022
  14. carljm
    added a commit that references this issue on Oct 17, 2022

    Merge branch 'main' into typewatch

    cdbe93b
  15. kumaraditya303
    unassigned
    graingert
    on May 7, 2023
  16. kumaraditya303 commented on May 11, 2023

    @kumaraditya303
    kumaraditya303
    on May 11, 2023
    Contributor
    More actions

    I'm closing this as done with good enough, there are plenty of places in stdlib where this happens and in those places some real work in done rather than just a function call. No point in spending more time on this.

  17. kumaraditya303
    closed this as completedon May 11, 2023
  18. github-project-automation
    moved this from Todo to Done in asyncioon May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesonly security fixestopic-asyncio

    Projects

    • asyncio
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.