This repository was archived by the owner on Nov 23, 2017. It is now read-only.
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
AttributeError: 'NoneType' object has no attribute 'get_debug' #390
Closed
Description
Writing unit tests for asyncio code, I have a few tests that fail occasionally with this error. It seems to be timing-related.
I use loop_context() from aiohttp to make sure all tests are isolated.
The problem is essentially that _loop is not set by the time logging is attempted, which may be related to the loop closing and unregistering after wait_for() canceled the job.
Traceback (most recent call last):
File "/../tests/fixtures.py", line 24, in wrapper
loop.run_until_complete(f(*args, loop=loop, **kwargs))
File "/usr/lib/python3.5/asyncio/base_events.py", line 387, in run_until_complete
return future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
...
File "....py", line 48, in ls
return await asyncio.wait_for(self.read_lines(command), 30.0, loop=self.loop)
File "/usr/lib/python3.5/asyncio/tasks.py", line 392, in wait_for
return fut.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "....py", line 58, in read_lines
stdin=asyncio.subprocess.DEVNULL
File "/usr/lib/python3.5/asyncio/subprocess.py", line 212, in create_subprocess_exec
stderr=stderr, **kwds)
File "/usr/lib/python3.5/asyncio/base_events.py", line 1079, in subprocess_exec
bufsize, **kwargs)
File "/usr/lib/python3.5/asyncio/unix_events.py", line 187, in _make_subprocess_transport
self._child_watcher_callback, transp)
File "/usr/lib/python3.5/asyncio/unix_events.py", line 808, in add_child_handler
self._do_waitpid(pid)
File "/usr/lib/python3.5/asyncio/unix_events.py", line 841, in _do_waitpid
if self._loop.get_debug():
AttributeError: 'NoneType' object has no attribute 'get_debug'
In this case, the culprit is this one, but the pattern repeats often in the code.
if self._loop.get_debug():
logger.debug('process %s exited with returncode %s',
expected_pid, returncode)
Metadata
Metadata
Assignees
Labels
No labels