self = <contextlib.ExitStack object at 0x7f0882429470>
exc_details = (<class 'ValueError'>, ValueError("<Token var=<ContextVar name='flask.request_ctx' at 0x7f08955e7f10> at 0x7f08822d5e58> was created in a different Context"), <traceback object at 0x7f08822f1788>)
received_exc = False
_fix_exception_context = <function ExitStack.__exit__.<locals>._fix_exception_context at 0x7f08900207b8>
suppressed_exc = False
def __exit__(self, *exc_details):
received_exc = exc_details[0] is not None
# We manipulate the exception state so it behaves as though
# we were actually nesting multiple with statements
frame_exc = sys.exc_info()[1]
def _fix_exception_context(new_exc, old_exc):
# Context may not be correct, so find the end of the chain
while 1:
exc_context = new_exc.__context__
if exc_context is old_exc:
# Context is already set correctly (see issue 20317)
return
if exc_context is None or exc_context is frame_exc:
break
new_exc = exc_context
# Change the end of the chain to point to the exception
# we expect it to reference
new_exc.__context__ = old_exc
# Callbacks are invoked in LIFO order to match the behaviour of
# nested context managers
suppressed_exc = False
pending_raise = False
while self._exit_callbacks:
is_sync, cb = self._exit_callbacks.pop()
assert is_sync
try:
> if cb(*exc_details):
/usr/lib/python3.7/contextlib.py:496:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
exc_type = None, exc = None, tb = None
def _exit_wrapper(exc_type, exc, tb):
> return cm_exit(cm, exc_type, exc, tb)
/usr/lib/python3.7/contextlib.py:377:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <flask.ctx.AppContext object at 0x7f08822e96d8>, exc_type = None
exc_value = None, tb = None
def __exit__(
self,
exc_type: t.Optional[type],
exc_value: t.Optional[BaseException],
tb: t.Optional[TracebackType],
) -> None:
> self.pop(exc_value)
.tox/py3/lib/python3.7/site-packages/flask/ctx.py:275:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <flask.ctx.AppContext object at 0x7f08822e96d8>, exc = None
def pop(self, exc: t.Optional[BaseException] = _sentinel) -> None: # type: ignore
"""Pops the app context."""
try:
if len(self._cv_tokens) == 1:
if exc is _sentinel:
exc = sys.exc_info()[1]
self.app.do_teardown_appcontext(exc)
finally:
ctx = _cv_app.get()
> _cv_app.reset(self._cv_tokens.pop())
E ValueError: <Token var=<ContextVar name='flask.app_ctx' at 0x7f08955e7eb8> at 0x7f08822d5fc0> was created in a different Context
.tox/py3/lib/python3.7/site-packages/flask/ctx.py:256: ValueError
During handling of the above exception, another exception occurred:
self = <swh.indexer.tests.storage.test_storage.TestIndexerStorageDirectoryIntrinsicMetadata object at 0x7f089306b588>
swh_indexer_storage_with_data = (<RemoteStorage url=mock://example.com/>, {'tools': {'swh-metadata-translator': {'id': 1, 'name': 'swh-metadata-transl...configuration_id=7, tool=None, id=b'\x01\xab\xea+\x95\xa9\xad\x87\x01\xad\xdfJ\xf9-h\xf41\xff:\x08', license=b'MIT')]})
def test_add_deadlock(
self, swh_indexer_storage_with_data: Tuple[IndexerStorageInterface, Any]
) -> None:
storage, data = swh_indexer_storage_with_data
etype = self.endpoint_type
tool = data.tools[self.tool_name]
hashes = [
hash_to_bytes("34973274ccef6ab4dfaaf86599792fa9c3fe4{:03d}".format(i))
for i in range(1000)
]
data_v1 = [
self.row_class.from_dict(
{
"id": hash_,
**self.example_data[0],
"indexer_configuration_id": tool["id"],
}
)
for hash_ in hashes
]
data_v2 = [
self.row_class.from_dict(
{
"id": hash_,
**self.example_data[1],
"indexer_configuration_id": tool["id"],
}
)
for hash_ in hashes
]
# Remove one item from each, so that both queries have to succeed for
# all items to be in the DB.
data_v2a = data_v2[1:]
data_v2b = list(reversed(data_v2[0:-1]))
# given
endpoint(storage, etype, "add")(data_v1)
# when
actual_data = sorted(
endpoint(storage, etype, "get")(hashes),
key=lambda x: x.id,
)
expected_data_v1 = [
self.row_class.from_dict(
{"id": hash_, **self.example_data[0], "tool": tool}
)
for hash_ in hashes
]
# then
assert actual_data == expected_data_v1
# given
def f1() -> None:
endpoint(storage, etype, "add")(data_v2a)
def f2() -> None:
endpoint(storage, etype, "add")(data_v2b)
t1 = threading.Thread(target=f1)
t2 = threading.Thread(target=f2)
t2.start()
t1.start()
t1.join()
t2.join()
actual_data = sorted(
> endpoint(storage, etype, "get")(hashes),
key=lambda x: x.id,
)
.tox/py3/lib/python3.7/site-packages/swh/indexer/tests/storage/test_storage.py:267:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:183: in meth_
return self._post(meth._endpoint_path, post_data)
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:272: in _post
**opts,
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:254: in raw_verb
return getattr(self.session, verb)(self._url(endpoint), **opts)
.tox/py3/lib/python3.7/site-packages/requests/sessions.py:635: in post
return self.request("POST", url, data=data, json=json, **kwargs)
.tox/py3/lib/python3.7/site-packages/requests/sessions.py:587: in request
resp = self.send(prep, **send_kwargs)
.tox/py3/lib/python3.7/site-packages/requests/sessions.py:701: in send
r = adapter.send(request, **kwargs)
.tox/py3/lib/python3.7/site-packages/swh/core/pytest_plugin.py:300: in send
data=request.body,
.tox/py3/lib/python3.7/site-packages/flask/testing.py:221: in open
self._context_stack.close()
/usr/lib/python3.7/contextlib.py:519: in close
self.__exit__(None, None, None)
/usr/lib/python3.7/contextlib.py:511: in __exit__
raise exc_details[1]
/usr/lib/python3.7/contextlib.py:496: in __exit__
if cb(*exc_details):
/usr/lib/python3.7/contextlib.py:377: in _exit_wrapper
return cm_exit(cm, exc_type, exc, tb)
.tox/py3/lib/python3.7/site-packages/flask/ctx.py:432: in __exit__
self.pop(exc_value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <RequestContext 'mock://example.com/directory_intrinsic_metadata/add' [POST] of swh.indexer.storage.api.server>
exc = ValueError("<Token var=<ContextVar name='flask.app_ctx' at 0x7f08955e7eb8> at 0x7f08822d5fc0> was created in a different Context")
def pop(self, exc: t.Optional[BaseException] = _sentinel) -> None: # type: ignore
"""Pops the request context and unbinds it by doing that. This will
also trigger the execution of functions registered by the
:meth:`~flask.Flask.teardown_request` decorator.
.. versionchanged:: 0.9
Added the `exc` argument.
"""
clear_request = len(self._cv_tokens) == 1
try:
if clear_request:
if exc is _sentinel:
exc = sys.exc_info()[1]
self.app.do_teardown_request(exc)
request_close = getattr(self.request, "close", None)
if request_close is not None:
request_close()
finally:
ctx = _cv_request.get()
token, app_ctx = self._cv_tokens.pop()
> _cv_request.reset(token)
E ValueError: <Token var=<ContextVar name='flask.request_ctx' at 0x7f08955e7f10> at 0x7f08822d5e58> was created in a different Context
.tox/py3/lib/python3.7/site-packages/flask/ctx.py:407: ValueError
TEST RESULT
TEST RESULT
- Run At
- Aug 3 2022, 2:46 PM