bieniu/brother

python 3.10 AttributeError

Closed this issue · 2 comments

Everything was fine but with the python update to 3.10 this happens:

loop = asyncio.get_event_loop()
Traceback (most recent call last):
; File "/usr/lib/python3.10/site-packages/pysnmp/carrier/asyncio/dgram/base.py", line 93, in openClientMode
self._lport = getattr(asyncio, 'async')(c)
;AttributeError: module 'asyncio' has no attribute 'async'
caused by <class 'AttributeError'>: module 'asyncio' has no attribute 'async'
/home/pepe/bin/Brother/brother.py:15: RuntimeWarning: coroutine 'BaseEventLoop.create_datagram_endpoint' was never awaited
return
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

I had a similar experience. The package is used with Home Assistant and the error I got was

Traceback (most recent call last):
  File "/srv/ha/lib/python3.10/site-packages/homeassistant/data_entry_flow.py", line 203, in async_init
    flow, result = await task
  File "/srv/ha/lib/python3.10/site-packages/homeassistant/data_entry_flow.py", line 230, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data, init_done)
  File "/srv/ha/lib/python3.10/site-packages/homeassistant/data_entry_flow.py", line 325, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/srv/ha/lib/python3.10/site-packages/homeassistant/components/brother/config_flow.py", line 97, in async_step_zeroconf
    await self.brother.async_update()
  File "/srv/ha/lib/python3.10/site-packages/brother/__init__.py", line 99, in async_update
    if not (raw_data := await self._get_data()):
  File "/srv/ha/lib/python3.10/site-packages/brother/__init__.py", line 233, in _get_data
    await self._init_device()
  File "/srv/ha/lib/python3.10/site-packages/brother/__init__.py", line 303, in _init_device
    errindication, errstatus, errindex, _ = await hlapi.getCmd(*request_args, *oids)
  File "/usr/local/lib/python3.10/asyncio/coroutines.py", line 124, in coro
    res = func(*args, **kw)
  File "/srv/ha/lib/python3.10/site-packages/pysnmp/hlapi/asyncio/cmdgen.py", line 151, in getCmd
    addrName, paramsName = lcd.configure(
  File "/srv/ha/lib/python3.10/site-packages/pysnmp/hlapi/lcd.py", line 91, in configure
    transport = transportTarget.openClientMode()
  File "/srv/ha/lib/python3.10/site-packages/pysnmp/hlapi/transport.py", line 53, in openClientMode
    self.transport = self.protoTransport().openClientMode(self.iface)
  File "/srv/ha/lib/python3.10/site-packages/pysnmp/carrier/asyncio/dgram/base.py", line 96, in openClientMode
    raise error.CarrierError(';'.join(traceback.format_exception(*sys.exc_info())))
pysnmp.carrier.error.CarrierError: Traceback (most recent call last):
;  File "/srv/ha/lib/python3.10/site-packages/pysnmp/carrier/asyncio/dgram/base.py", line 93, in openClientMode
    self._lport = getattr(asyncio, 'async')(c)
;AttributeError: module 'asyncio' has no attribute 'async'
caused by <class 'AttributeError'>: module 'asyncio' has no attribute 'async'

This problem is related to pysnmp module etingof/pysnmp#413