Bug 2059952 - python-dbus-next fails to build with pytest 7
Summary: python-dbus-next fails to build with pytest 7
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: python-dbus-next
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Aleksei Bavshin
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: PYTEST7
TreeView+ depends on / blocked
 
Reported: 2022-03-02 11:53 UTC by Miro Hrončok
Modified: 2022-03-06 12:47 UTC (History)
1 user (show)

Fixed In Version: python3-pytest-asyncio-0.18.1-1.fc37
Clone Of:
Environment:
Last Closed: 2022-03-06 12:47:24 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Miro Hrončok 2022-03-02 11:53:53 UTC
In this copr repo, I have updated pytest to 7.0.1:

https://copr.fedorainfracloud.org/coprs/churchyard/pytest-7/

Based on this PR:

https://src.fedoraproject.org/rpms/pytest/pull-request/25

I'd like to update pytest to 7 in Fedora 37, but python-dbus-next 0.2.3-2 fails to build.

https://copr.fedorainfracloud.org/coprs/churchyard/pytest-7/package/python-dbus-next/

______________________ test_high_level_service_fd_passing ______________________

event_loop = <_UnixSelectorEventLoop running=False closed=False debug=False>

    @pytest.mark.asyncio
    async def test_high_level_service_fd_passing(event_loop):
        bus1 = await MessageBus(negotiate_unix_fd=True).connect()
        bus2 = await MessageBus(negotiate_unix_fd=True).connect()
    
        interface_name = 'test.interface'
        interface = ExampleInterface(interface_name)
        export_path = '/test/path'
    
        async def call(member, signature='', body=[], unix_fds=[], iface=interface.name):
            return await bus2.call(
                Message(destination=bus1.unique_name,
                        path=export_path,
                        interface=iface,
                        member=member,
                        signature=signature,
                        body=body,
                        unix_fds=unix_fds))
    
        bus1.export(export_path, interface)
    
        # test that an fd can be returned by the service
        reply = await call('ReturnsFd')
        assert reply.message_type == MessageType.METHOD_RETURN, reply.body
        assert reply.signature == 'h'
        assert len(reply.unix_fds) == 1
        assert_fds_equal(interface.get_last_fd(), reply.unix_fds[0])
        interface.cleanup()
        os.close(reply.unix_fds[0])
    
        # test that an fd can be sent to the service
        fd = open_file()
        reply = await call('AcceptsFd', signature='h', body=[0], unix_fds=[fd])
        assert reply.message_type == MessageType.METHOD_RETURN, reply.body
        assert_fds_equal(interface.get_last_fd(), fd)
    
        interface.cleanup()
        os.close(fd)
    
        # signals
        fut = event_loop.create_future()
    
        def fd_listener(msg):
            if msg.sender == bus1.unique_name and msg.message_type == MessageType.SIGNAL:
                fut.set_result(msg)
    
        reply = await bus2.call(
            Message(destination='org.freedesktop.DBus',
                    path='/org/freedesktop/DBus',
                    member='AddMatch',
                    signature='s',
                    body=[f"sender='{bus1.unique_name}'"]))
        assert reply.message_type == MessageType.METHOD_RETURN
    
        bus2.add_message_handler(fd_listener)
        interface.SignalFd()
        reply = await fut
    
        assert len(reply.unix_fds) == 1
        assert reply.body == [0]
        assert_fds_equal(reply.unix_fds[0], interface.get_last_fd())
    
        interface.cleanup()
        os.close(reply.unix_fds[0])
    
        # properties
>       reply = await call('Get',
                           'ss', [interface_name, 'PropFd'],
                           iface='org.freedesktop.DBus.Properties')

test/test_fd_passing.py:180: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test/test_fd_passing.py:124: in call
    return await bus2.call(
dbus_next/aio/message_bus.py:303: in call
    self._call(msg, reply_handler)
dbus_next/message_bus.py:588: in _call
    self.send(msg)
dbus_next/aio/message_bus.py:326: in send
    self._writer.schedule_write(msg, future)
dbus_next/aio/message_bus.py:85: in schedule_write
    self.loop.add_writer(self.fd, self.write_callback)
/usr/lib64/python3.10/asyncio/selector_events.py:346: in add_writer
    self._add_writer(fd, callback, *args)
/usr/lib64/python3.10/asyncio/selector_events.py:304: in _add_writer
    self._selector.modify(fd, mask | selectors.EVENT_WRITE,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <selectors.EpollSelector object at 0x7f430f6f3130>, fileobj = 20
events = 3
data = (<Handle MessageBus._message_reader()>, <Handle _MessageWriter.write_callback()>)

    def modify(self, fileobj, events, data=None):
        try:
            key = self._fd_to_key[self._fileobj_lookup(fileobj)]
        except KeyError:
            raise KeyError(f"{fileobj!r} is not registered") from None
    
        changed = False
        if events != key.events:
            selector_events = 0
            if events & EVENT_READ:
                selector_events |= self._EVENT_READ
            if events & EVENT_WRITE:
                selector_events |= self._EVENT_WRITE
            try:
>               self._selector.modify(key.fd, selector_events)
E               OSError: [Errno 9] Bad file descriptor

/usr/lib64/python3.10/selectors.py:390: OSError



Honestly, this might not be pytest related at all, but rather copr related, but another build with pytest 6 succeeded.

I've submitted several more rebuilds to see if this is not just flaky.


There are several packages affected by this update, so I'd very much appreciate it if you could fix this failure. Please, check if your upstream hasn't already fixed it and backport the fix if possible. Report this failure to your upstream otherwise. If you need specific help, let me know.

Thanks!

Comment 1 Miro Hrončok 2022-03-02 12:00:16 UTC
> I've submitted several more rebuilds to see if this is not just flaky.

All failed.

Comment 2 Aleksei Bavshin 2022-03-02 19:27:04 UTC
I've reproduced the problem after updating pytest in the upstream's containerized test setup. Seems to be passing again with 'pytest-asyncio >= 0.17.0' (I don't see anything relevant in the pytest-asyncio changelog though).

https://src.fedoraproject.org/rpms/python3-pytest-asyncio/pull-request/4 should fix the build.

Comment 3 Miro Hrončok 2022-03-06 12:47:24 UTC
> https://src.fedoraproject.org/rpms/python3-pytest-asyncio/pull-request/4 should fix the build.

It did. Thanks for investigating!


Note You need to log in before you can comment on or make changes to this bug.