Code Monkey home page Code Monkey logo

Comments (7)

XuanWang-Amos avatar XuanWang-Amos commented on June 19, 2024

Can you share more information about how the test is set up?

I'm seeing Exception ignored message, but we're intentionally ignore DeprecationWarning for Python 3.12.

from grpc.

mukund-ananthu avatar mukund-ananthu commented on June 19, 2024

googleapis/python-pubsub#1095 has reference to failure builds, if that helps.

from grpc.

parthea avatar parthea commented on June 19, 2024

I was able to re-create the resource warning with the following code. The warning only appears when using python 3.12

import grpc
from grpc import aio

print(grpc.__version__)

aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) 
1.62.0
/usr/local/google/home/partheniou/.pyenv/versions/3.12.0/lib/python3.12/asyncio/base_events.py:703: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
Object allocated at (most recent call last):
  File "/usr/local/google/home/partheniou/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", lineno 39
    cli.main()
  File "/usr/local/google/home/partheniou/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", lineno 430
    run()
  File "/usr/local/google/home/partheniou/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", lineno 284
    runpy.run_path(target, run_name="__main__")
  File "/usr/local/google/home/partheniou/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", lineno 321
    return _run_module_code(code, init_globals, run_name,
  File "/usr/local/google/home/partheniou/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", lineno 135
    _run_code(code, mod_globals, init_globals,
  File "/usr/local/google/home/partheniou/.vscode-server/extensions/ms-python.debugpy-2024.0.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", lineno 124
    exec(code, run_globals)
  File "/usr/local/google/home/partheniou/git/python-pubsub/check.py", lineno 7
    aio.secure_channel(target, grpc.local_channel_credentials())
  File "/usr/local/google/home/partheniou/.pyenv/versions/3.12.0/envs/py3120env/lib/python3.12/site-packages/grpc/aio/_channel.py", lineno 597
    return Channel(
  File "/usr/local/google/home/partheniou/.pyenv/versions/3.12.0/envs/py3120env/lib/python3.12/site-packages/grpc/aio/_channel.py", lineno 367
    self._loop = cygrpc.get_working_loop()
  File "/usr/local/google/home/partheniou/.pyenv/versions/3.12.0/lib/python3.12/asyncio/events.py", lineno 716
    return self._loop_factory()

from grpc.

XuanWang-Amos avatar XuanWang-Amos commented on June 19, 2024

@parthea I tried your code and not able to reproduce in both 3.12.0 and 3.12.1, is there other setup required to reproduce the issue?

from grpc.

parthea avatar parthea commented on June 19, 2024

@XuanWang-Amos

Please can you try this code sample instead?

The following packages are needed
google-auth
requests

import grpc
from grpc import aio
print(grpc.__version__)

import google.auth
import google.auth.credentials
import google.auth.transport.grpc
import google.auth.transport.requests

default_scopes=('https://www.googleapis.com/auth/cloud-platform','https://www.googleapis.com/auth/pubsub')
credentials = google.auth.credentials.with_scopes_if_required(
            google.auth.credentials.AnonymousCredentials(), scopes=[], default_scopes=default_scopes
        )
request = google.auth.transport.requests.Request()
default_host='pubsub.googleapis.com'
metadata_plugin = google.auth.transport.grpc.AuthMetadataPlugin(
        credentials,
        request,
        default_host=default_host,
    )
google_auth_credentials = grpc.metadata_call_credentials(metadata_plugin)
target ='pubsub.googleapis.com:443'
grpc_creds = grpc.compute_engine_channel_credentials(google_auth_credentials)
options=[('grpc.max_send_message_length', -1), ('grpc.max_receive_message_length', -1), ('grpc.max_metadata_size', 4194304), ('grpc.keepalive_time_ms', 30000)]
aio.secure_channel(
        target, grpc_creds, options
    )
aio.secure_channel(
        target, grpc_creds, options
    )
aio.secure_channel(
        target, grpc_creds, options
    )

from grpc.

parthea avatar parthea commented on June 19, 2024

I see the warnings when I exit the python terminal

>>> exit()
/usr/local/lib/python3.12/asyncio/base_events.py:703: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/usr/local/lib/python3.12/asyncio/base_events.py:703: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback

from grpc.

parthea avatar parthea commented on June 19, 2024

I can still reproduce the issue with #35974 (comment), but the warning only appears when I exit the terminal.

>>> 
>>> aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) 
<grpc.aio._channel.Channel object at 0x7fefed7d1e50>
>>> aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) 
<grpc.aio._channel.Channel object at 0x7fefed7d0ec0>
>>> aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) 
<grpc.aio._channel.Channel object at 0x7fefed7d1be0>
>>> aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) 
<grpc.aio._channel.Channel object at 0x7fefed7d1e50>
>>> aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) 
<grpc.aio._channel.Channel object at 0x7fefed7d0ec0>
>>> exit()
/usr/local/lib/python3.12/asyncio/base_events.py:703: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/usr/local/lib/python3.12/asyncio/base_events.py:703: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/usr/local/lib/python3.12/asyncio/base_events.py:703: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/usr/local/lib/python3.12/asyncio/base_events.py:703: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
  _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
/usr/local/lib/python3.12/asyncio/base_events.py:703: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>

from grpc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.