grafana-toolbox / grafana-wtf

Grep through all Grafana entities in the spirit of git-wtf.
GNU Affero General Public License v3.0
143 stars 13 forks source link

CI croaks on Python 3.12.0a3 #46

Closed amotl closed 1 year ago

amotl commented 1 year ago

As we can see at ^1, running the tests on Python 3.12-dev currently croaks, while it has worked before. See also GH-57.

___________________________ test_find_textual_empty ____________________________

docker_grafana = 'http://127.0.0.1:33333/'
capsys = <_pytest.capture.CaptureFixture object at 0x7f099215e510>

    def test_find_textual_empty(docker_grafana, capsys):

        # Run command and capture output.
        set_command("find foobar")
>       grafana_wtf.commands.run()

tests/test_commands.py:46: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
grafana_wtf/commands.py:192: in run
    engine.scan_common()
grafana_wtf/core.py:115: in scan_common
    self.scan_dashboards()
grafana_wtf/core.py:196: in scan_dashboards
    self.fetch_dashboards_parallel()
grafana_wtf/core.py:230: in fetch_dashboards_parallel
    loop = asyncio.get_event_loop()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at 0x7f0991fc6f90>

    def get_event_loop(self):
        """Get the event loop for the current context.

        Returns an instance of EventLoop or raises an exception.
        """
        if self._local._loop is None:
>           raise RuntimeError('There is no current event loop in thread %r.'
                               % threading.current_thread().name)
E           RuntimeError: There is no current event loop in thread 'MainThread'.

/opt/hostedtoolcache/Python/3.12.0-alpha.3/x64/lib/python3.12/asyncio/events.py:676: RuntimeError
amotl commented 1 year ago

This may have happened due to a new alpha release of Python 3.12. And, indeed:

While the GHA Python versions manifest does not reveal any significant information about release dates, we discovered this patch when following https://github.com/python/cpython/compare/v3.12.0a2...v3.12.0a3, and it very much looks like this one is responsible for the observed behavior.

It reads:

get_event_loop() will now raise a RuntimeError if no current event loop was set, instead of creating and setting a new event loop.

/cc @hramezani, @quodt

amotl commented 1 year ago

It looks like the removal of the implicit creation of an event loop by get_event_loop() will get postponed to Python 3.14, and the previous behavior will be restored with the next patch release of Python 3.12 alpha.

amotl commented 1 year ago

It looks like the issue has been resolved with Python 3.12 alpha 5, indicated by that GH-57 now passes successfully.

-- https://github.com/panodata/grafana-wtf/actions/runs/4333760552/jobs/7567157354